-
Notifications
You must be signed in to change notification settings - Fork 31
Open
Description
Given the following SQL schema:
CREATE TABLE authors (
id BIGSERIAL PRIMARY KEY,
class text NOT NULL
);
sqlc will generate the following python code :
class Author(pydantic.BaseModel):
id: int
class: str
This is not a valid python code :
>>> import pydantic
...
...
... class Author(pydantic.BaseModel):
... id: int
... class: str
...
File "<python-input-0>", line 6
class: str
^
SyntaxError: invalid syntax
This is due to class
to be a reserved python keyword.
Note that it will also fails if you use if
, not
, in
, etc...
I have generated an example on my fork: https://github.com/Escape-Technologies/sqlc-gen-python/tree/19e8d56813a83664bc19c12a3121e84e8bc7af66/internal/endtoend/testdata/emit_pydantic_models_with_fields
Metadata
Metadata
Assignees
Labels
No labels