- Notifications
You must be signed in to change notification settings - Fork39
Open
Description
Given the following SQL schema:
CREATETABLEauthors ( idBIGSERIALPRIMARY KEY, classtextNOT NULL);
sqlc will generate the following python code :
classAuthor(pydantic.BaseModel):id:intclass: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 syntaxThis is due toclass to be a reserved python keyword.
Note that it will also fails if you useif,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