Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Invalid name generation when using python reserved keywords #88

Open
@QuentinN42

Description

@QuentinN42

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 syntax

This 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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp