René's URL Explorer Experiment


Title: Order of columns in the table created does not have 'id' first, despite the order in the SQLModel. Looks like it's prioritising fields with sa_column · Issue #542 · fastapi/sqlmodel · GitHub

Open Graph Title: Order of columns in the table created does not have 'id' first, despite the order in the SQLModel. Looks like it's prioritising fields with sa_column · Issue #542 · fastapi/sqlmodel

X Title: Order of columns in the table created does not have 'id' first, despite the order in the SQLModel. Looks like it's prioritising fields with sa_column · Issue #542 · fastapi/sqlmodel

Description: First Check I added a very descriptive title to this issue. I used the GitHub search to find a similar issue and didn't find it. I searched the SQLModel documentation, with the integrated search. I already searched in Google "How to X in...

Open Graph Description: First Check I added a very descriptive title to this issue. I used the GitHub search to find a similar issue and didn't find it. I searched the SQLModel documentation, with the integrated search. I...

X Description: First Check I added a very descriptive title to this issue. I used the GitHub search to find a similar issue and didn't find it. I searched the SQLModel documentation, with the integrated searc...

Opengraph URL: https://github.com/fastapi/sqlmodel/issues/542

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Order of columns in the table created does not have 'id' first, despite the order in the SQLModel. Looks like it's prioritising fields with sa_column","articleBody":"### First Check\r\n\r\n- [X] I added a very descriptive title to this issue.\r\n- [X] I used the GitHub search to find a similar issue and didn't find it.\r\n- [X] I searched the SQLModel documentation, with the integrated search.\r\n- [X] I already searched in Google \"How to X in SQLModel\" and didn't find any information.\r\n- [X] I already read and followed all the tutorial in the docs and didn't find an answer.\r\n- [X] I already checked if it is not related to SQLModel but to [Pydantic](https://github.com/samuelcolvin/pydantic).\r\n- [X] I already checked if it is not related to SQLModel but to [SQLAlchemy](https://github.com/sqlalchemy/sqlalchemy).\r\n\r\n### Commit to Help\r\n\r\n- [X] I commit to help with one of those options 👆\r\n\r\n### Example Code\r\n\r\n```python\r\nfrom sqlmodel import Field, SQLModel, JSON, Column, Time\r\n\r\nclass MyTable(SQLModel, table=True):\r\n    id: int | None = Field(default=None, primary_key=True)\r\n    name: str\r\n    type: str\r\n    slug: str = Field(index=True, unique=True)\r\n    resource_data: dict | None = Field(default=None, sa_column=Column(JSON))  # type: ignore\r\n\r\n\r\n# ... create engine\r\n\r\nSQLModel.metadata.create_all(engine)\r\n```\r\n\r\n\r\n### Description\r\n\r\nThe CREATE table script generated for the model above ends up putting resource_data as the first column, instead of preserving the natural order of 'id' first\r\n\r\n```\r\nCREATE TABLE mytable (\r\n     resource_data JSON,          \u003c----- why is this the FIRST column created?\r\n     id SERIAL NOT NULL, \r\n     name VARCHAR NOT NULL, \r\n     type VARCHAR NOT NULL, \r\n     slug VARCHAR NOT NULL, \r\n     PRIMARY KEY (id)\r\n)\r\n```\r\n\r\nThis feels unusual when I inspect my postgresql tables in a db tool like pgAdmin.\r\n\r\nHow do I ensure the table is created with the 'natural' order?\r\n\r\n### Operating System\r\n\r\nmacOS\r\n\r\n### Operating System Details\r\n\r\n_No response_\r\n\r\n### SQLModel Version\r\n\r\n0.0.8\r\n\r\n### Python Version\r\n\r\n3.11.1\r\n\r\n### Additional Context\r\n\r\n_No response_","author":{"url":"https://github.com/epicwhale","@type":"Person","name":"epicwhale"},"datePublished":"2023-01-29T14:11:08Z","url":"https://github.com/fastapi/sqlmodel/issues/542"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:f69d8431-7dea-359c-5df8-0b3a5c658db5
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id8D6C:24FA46:B2F1E0:F33989:6AFE6969
html-safe-noncedfbe71f19cc25976bba755e6200b34071ee6edbacb29ea1b34e63ff515eebdde
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RDZDOjI0RkE0NjpCMkYxRTA6RjMzOTg5OjZBRkU2OTY5IiwidmlzaXRvcl9pZCI6IjI3MDY5MTQ0MDkwNjg4OTU3NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmacb0e86c70a61a3d542f333c06b79c9dcd3c6b9d67ca538f011c62b5b81bca669e
hovercard-subject-tagissue:1561306134
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/fastapi/sqlmodel/542/issue_layout
twitter:imagehttps://opengraph.githubassets.com/aafd7356d69ac949080de2abf6a0e6632fb99c1018c76bb27c67c51852d0dc76/fastapi/sqlmodel/issues/542
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/aafd7356d69ac949080de2abf6a0e6632fb99c1018c76bb27c67c51852d0dc76/fastapi/sqlmodel/issues/542
og:image:altFirst Check I added a very descriptive title to this issue. I used the GitHub search to find a similar issue and didn't find it. I searched the SQLModel documentation, with the integrated search. I...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameepicwhale
hostnamegithub.com
expected-hostnamegithub.com
Noneb3c0f155eafc27e60db6e254d1ffff0e072e9ab3b4018a5ee518797c19d89f86
turbo-cache-controlno-preview
go-importgithub.com/fastapi/sqlmodel git https://github.com/fastapi/sqlmodel.git
octolytics-dimension-user_id156354296
octolytics-dimension-user_loginfastapi
octolytics-dimension-repository_id399495186
octolytics-dimension-repository_nwofastapi/sqlmodel
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id399495186
octolytics-dimension-repository_network_root_nwofastapi/sqlmodel
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release4a10310af51a1bfffbedc4fd81cb582acf0cb0ff
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/fastapi/sqlmodel/issues/542#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Ffastapi%2Fsqlmodel%2Fissues%2F542
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Ffastapi%2Fsqlmodel%2Fissues%2F542
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=fastapi%2Fsqlmodel
Reloadhttps://github.com/fastapi/sqlmodel/issues/542
Reloadhttps://github.com/fastapi/sqlmodel/issues/542
Reloadhttps://github.com/fastapi/sqlmodel/issues/542
fastapihttps://github.com/fastapi
sqlmodelhttps://github.com/fastapi/sqlmodel
Codehttps://github.com/fastapi/sqlmodel
Issues1 (1)https://github.com/fastapi/sqlmodel/issues
Pull requests53 (53)https://github.com/fastapi/sqlmodel/pulls
Discussionshttps://github.com/fastapi/sqlmodel/discussions
Actionshttps://github.com/fastapi/sqlmodel/actions
Projectshttps://github.com/fastapi/sqlmodel/projects
Security and qualityhttps://github.com/fastapi/sqlmodel/security
Insightshttps://github.com/fastapi/sqlmodel/insights
https://github.com/fastapi/sqlmodel
New issuehttps://github.com/login?return_to=https://github.com/fastapi/sqlmodel/issues/542
New issuehttps://github.com/login?return_to=https://github.com/fastapi/sqlmodel/issues/542
Order of columns in the table created does not have 'id' first, despite the order in the SQLModel. Looks like it's prioritising fields with sa_columnhttps://github.com/fastapi/sqlmodel/issues/542#top
questionFurther information is requestedhttps://github.com/fastapi/sqlmodel/issues?q=state%3Aopen%20label%3A%22question%22
https://github.com/epicwhale
epicwhalehttps://github.com/epicwhale
on Jan 29, 2023https://github.com/fastapi/sqlmodel/issues/542#issue-1561306134
Pydantichttps://github.com/samuelcolvin/pydantic
SQLAlchemyhttps://github.com/sqlalchemy/sqlalchemy
epicwhalehttps://github.com/epicwhale
questionFurther information is requestedhttps://github.com/fastapi/sqlmodel/issues?q=state%3Aopen%20label%3A%22question%22
on Jan 29, 2023https://github.com/fastapi/sqlmodel/issues/542#event-8381903092
https://github.com/H-Plus-Time
H-Plus-Timehttps://github.com/H-Plus-Time
on Feb 15, 2023https://github.com/fastapi/sqlmodel/issues/542#issuecomment-1430830482
stackoverflow.com/sqlalchemy-move-mixin-columns-to-endhttps://stackoverflow.com/questions/3923910/sqlalchemy-move-mixin-columns-to-end
#436https://github.com/fastapi/sqlmodel/pull/436
https://github.com/LastNever
LastNeverhttps://github.com/LastNever
on Mar 23, 2023https://github.com/fastapi/sqlmodel/issues/542#issuecomment-1480769705
stackoverflow.com/sqlalchemy-move-mixin-columns-to-endhttps://stackoverflow.com/questions/3923910/sqlalchemy-move-mixin-columns-to-end
#436https://github.com/fastapi/sqlmodel/pull/436
https://github.com/cout
couthttps://github.com/cout
on May 10, 2024https://github.com/fastapi/sqlmodel/issues/542#issuecomment-2105011973
https://github.com/prurph
prurphhttps://github.com/prurph
on Jul 20, 2024https://github.com/fastapi/sqlmodel/issues/542#issuecomment-2240883883
https://github.com/ideepu
ideepuhttps://github.com/ideepu
on Sep 9, 2024https://github.com/fastapi/sqlmodel/issues/542#issuecomment-2338251042
@prurphhttps://github.com/prurph
dochttps://docs.sqlalchemy.org/en/20/changelog/whatsnew_20.html#orm-declarative-applies-column-orders-differently-control-behavior-using-sort-order
https://docs.sqlalchemy.org/en/20/orm/mapping_api.html#sqlalchemy.orm.mapped_column.params.sort_orderhttps://docs.sqlalchemy.org/en/20/orm/mapping_api.html#sqlalchemy.orm.mapped_column.params.sort_order
https://pypi.org/project/SQLAlchemy/2.0.34/https://pypi.org/project/SQLAlchemy/2.0.34/
https://github.com/oYASo
oYASohttps://github.com/oYASo
on Sep 12, 2024https://github.com/fastapi/sqlmodel/issues/542#issuecomment-2346282766
@prurphhttps://github.com/prurph
https://github.com/cobnett3
cobnett3https://github.com/cobnett3
on Oct 15, 2024https://github.com/fastapi/sqlmodel/issues/542#issuecomment-2413355862
https://github.com/hjqlc
hjqlchttps://github.com/hjqlc
on Nov 22, 2024https://github.com/fastapi/sqlmodel/issues/542#issuecomment-2493589894
@prurphhttps://github.com/prurph
Columnhttps://docs.sqlalchemy.org/en/20/core/metadata.html#sqlalchemy.schema.Column
https://private-user-images.githubusercontent.com/31725690/388924598-c19202fa-31b2-4ba7-b1da-a3e2cf255cbe.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3OTUwNTgzMjUsIm5iZiI6MTc5NTA1ODAyNSwicGF0aCI6Ii8zMTcyNTY5MC8zODg5MjQ1OTgtYzE5MjAyZmEtMzFiMi00YmE3LWIxZGEtYTNlMmNmMjU1Y2JlLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNjExMTklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjYxMTE5VDAzMTM0NVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWU1ZGQxMmUyY2YwNzEwMGMxNTViZDQzYTEyZGU2ZWUzM2Y4YzRkM2E1MGU0NzhjMWZmODE4NGU0YTY3Mzg5YTAmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JnJlc3BvbnNlLWNvbnRlbnQtdHlwZT1pbWFnZSUyRnBuZyJ9.DoVLE8L1CATeWfxV6sj-UxnRZSB2lQczdpsHNTuL3SQ
https://github.com/kssion
kssionhttps://github.com/kssion
on Jul 31, 2025https://github.com/fastapi/sqlmodel/issues/542#issuecomment-3139194575
https://github.com/YuriiMotov
YuriiMotovhttps://github.com/YuriiMotov
on Aug 15, 2025https://github.com/fastapi/sqlmodel/issues/542#issuecomment-3191620289
@hjqlchttps://github.com/hjqlc
mentionedhttps://github.com/fastapi/sqlmodel/issues/542#issuecomment-2493589894
workaround with inheritance orderhttps://github.com/fastapi/sqlmodel/issues/542#issuecomment-2346282766
@oYASohttps://github.com/oYASo
YuriiMotovhttps://github.com/YuriiMotov
completedhttps://github.com/fastapi/sqlmodel/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Aug 15, 2025https://github.com/fastapi/sqlmodel/issues/542#event-19176818257
Sign up for freehttps://github.com/signup?return_to=https://github.com/fastapi/sqlmodel/issues/542
Sign in to commenthttps://github.com/login?return_to=https://github.com/fastapi/sqlmodel/issues/542
questionFurther information is requestedhttps://github.com/fastapi/sqlmodel/issues?q=state%3Aopen%20label%3A%22question%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.