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#89

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
QuentinN42 wants to merge5 commits intosqlc-dev:main
base:main
Choose a base branch
Loading
fromEscape-Technologies:main

Conversation

@QuentinN42
Copy link

Fixes#88

To fix this issue, here is my proposition:

 class Author(pydantic.BaseModel):+     model_config = pydantic.ConfigDict(+        validate_by_alias=True,+        validate_by_name=True,+    )     id: int+    class_: str = pydantic.Field(+        alias="class",+    )-    class: str
  1. I'm replacing theclass reserved keyword byclass_.
  2. I addvalidate_by_name to allow us to define the class usingAuthor(class_=...).
  3. I addvalidate_by_alias to allow JSON serde.

Changes overview

  1. I've created a new file :internal/poet/reserved.go to append_ to reserved names.
  2. I've modifiedinternal/gen.go::pydanticNode to addmodel_config = pydantic.ConfigDict
  3. I've modifiedinternal/gen.go::fieldNode:
  • If not reserved keyword, code unchanged.
  • Else if using pydantic, add the_ and addpydantic.Field(...)
  • Else if dataclasses, only add the_
  1. Added tests

Questions / possible issues

  1. To run the tests, I just clonned the repo and ranmake test is it correct ?
  2. I had to update all comment fromsqlc v1.28.0 tosqlc v1.29.0 is this intended ?
  3. The wasm sha256 changed, should I commit that ?
  4. Ininternal/poet/reserved.go I hardcodedreservedKeywords we should double check it and check if we want to keep it like that.
  5. Do you want me to add more tests ?

…n reserved keywordsSigned-off-by: QuentinN42 <quentin@lieumont.fr>
Signed-off-by: QuentinN42 <quentin@lieumont.fr>
Signed-off-by: QuentinN42 <quentin@lieumont.fr>
…figDictSigned-off-by: QuentinN42 <quentin@lieumont.fr>
Signed-off-by: QuentinN42 <quentin@lieumont.fr>
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Invalid name generation when using python reserved keywords

1 participant

@QuentinN42

[8]ページ先頭

©2009-2025 Movatter.jp