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: github.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:0923eca4-fb46-a72d-c5ba-c89ded893eb8 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | ADD2:4DF1B:414B7EA:576386D:696DE97F |
| html-safe-nonce | f8064688e2c8678898cbf85044d46e04cc209c048bfcc546ec81a65cbadfc4a8 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBREQyOjRERjFCOjQxNEI3RUE6NTc2Mzg2RDo2OTZERTk3RiIsInZpc2l0b3JfaWQiOiI0ODU0Mjg1NjY3MzYyNzkzODU1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | c65f72f573ae0f6747cc856c36ddc2c0a76b515846cd621c2c8df47fe6c3959d |
| 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