Title: Invalid name generation when using python reserved keywords · Issue #88 · sqlc-dev/sqlc-gen-python · GitHub
Open Graph Title: Invalid name generation when using python reserved keywords · Issue #88 · sqlc-dev/sqlc-gen-python
X Title: Invalid name generation when using python reserved keywords · Issue #88 · sqlc-dev/sqlc-gen-python
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 :...
Open Graph 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 clas...
X 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 clas...
Opengraph URL: https://github.com/sqlc-dev/sqlc-gen-python/issues/88
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Invalid name generation when using python reserved keywords","articleBody":"Given the following SQL schema:\n\n```sql\nCREATE TABLE authors (\n id BIGSERIAL PRIMARY KEY,\n class text NOT NULL\n);\n```\n\nsqlc will generate the following python code :\n\n```python\nclass Author(pydantic.BaseModel):\n id: int\n class: str\n```\n\nThis is not a valid python code :\n\n```\n\u003e\u003e\u003e import pydantic\n... \n... \n... class Author(pydantic.BaseModel):\n... id: int\n... class: str\n... \n File \"\u003cpython-input-0\u003e\", line 6\n class: str\n ^\nSyntaxError: invalid syntax\n```\n\nThis is due to `class` to be a reserved python keyword.\nNote that it will also fails if you use `if`, `not`, `in`, etc...\n\nI 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","author":{"url":"https://github.com/QuentinN42","@type":"Person","name":"QuentinN42"},"datePublished":"2025-07-25T13:38:10.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/88/sqlc-gen-python/issues/88"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:1554c223-7cae-42b8-bb32-019081cf0d0b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A5B2:283961:62DD1FA:81B6C34:696DAC25 |
| html-safe-nonce | fd553e2aad89a31914bb720cb2e3acc7d16be4f46265657c17b47dd17b03cdd2 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNUIyOjI4Mzk2MTo2MkREMUZBOjgxQjZDMzQ6Njk2REFDMjUiLCJ2aXNpdG9yX2lkIjoiNTc2MDQ5Nzc1MjIwMTg2NjI3NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 1a9b672641b6ae3616ec98ff3799e4b287b748b6315bd8685491663f079cf326 |
| hovercard-subject-tag | issue:3263269147 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/sqlc-dev/sqlc-gen-python/88/issue_layout |
| twitter:image | https://opengraph.githubassets.com/99b845d3123a1cd146d45d3836aae7579719458405565399ac9368532212212f/sqlc-dev/sqlc-gen-python/issues/88 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/99b845d3123a1cd146d45d3836aae7579719458405565399ac9368532212212f/sqlc-dev/sqlc-gen-python/issues/88 |
| og:image:alt | 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 clas... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | QuentinN42 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4922b452d03cd8dbce479d866a11bc25b59ef6ee2da23aa9b0ddefa6bd4d0064 |
| turbo-cache-control | no-preview |
| go-import | github.com/sqlc-dev/sqlc-gen-python git https://github.com/sqlc-dev/sqlc-gen-python.git |
| octolytics-dimension-user_id | 136738596 |
| octolytics-dimension-user_login | sqlc-dev |
| octolytics-dimension-repository_id | 548530161 |
| octolytics-dimension-repository_nwo | sqlc-dev/sqlc-gen-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 548530161 |
| octolytics-dimension-repository_network_root_nwo | sqlc-dev/sqlc-gen-python |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 7e5ae23c70136152637ceee8d6faceb35596ec46 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width