-
Notifications
You must be signed in to change notification settings - Fork 24
Closed
Description
Describe the bug
NOW() is not recognized as equivalent to now() when used as a default value, even though SQL is case-insensitive.
To Reproduce
Given the following SQL:
ddl = """
CREATE TABLE asdf (
t TIMESTAMP DEFAULT NOW()
);
"""
print(omymodels.create_models(ddl=ddl, models_type="dataclass")["code"])The output is
import datetime
from dataclasses import dataclass
@dataclass
class Asdf:
t: datetime.datetime = 'NOW()' # Default value is wrongNote that, while the datatype of the column is correct, the default value is a string instead of a call to datetime.datetime.now(). If we make NOW()` lowercase, we get the expected output.
import datetime
from dataclasses import dataclass
@dataclass
class Asdf:
t: datetime.datetime = datetime.datetime.now()n.b. the expected output has a bug in it which I'll file a separate ticket for
Expected behavior
SQL is case-insensitive, therefore now() and NOW() should behave identically and produce the same output.
Additional context
Python: 3.8.2
Version: 0.8.1
xnuinside
Metadata
Metadata
Assignees
Labels
No labels