Title: SQLAlchemy version 1.4.36 breaks SQLModel relationships · Issue #315 · fastapi/sqlmodel · GitHub
Open Graph Title: SQLAlchemy version 1.4.36 breaks SQLModel relationships · Issue #315 · fastapi/sqlmodel
X Title: SQLAlchemy version 1.4.36 breaks SQLModel relationships · Issue #315 · 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/315
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"SQLAlchemy version 1.4.36 breaks SQLModel relationships","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**👆 Not quite true - this is definitely related to 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 typing import Optional\r\n\r\nfrom sqlmodel import Field, Relationship, SQLModel\r\n\r\n\r\nclass City(SQLModel, table=True):\r\n name: str = Field(primary_key=True)\r\n heroes: \"Hero\" = Relationship(back_populates=\"city\")\r\n\r\nclass Hero(SQLModel, table=True):\r\n name: str = Field(primary_key=True)\r\n city_name: Optional[str] = Field(default=None,foreign_key=\"city.name\")\r\n city: Optional[City] = Relationship(back_populates=\"heroes\",\r\n sa_relationship_kwargs=dict(cascade=\"all,delete\")\r\n )\r\n\r\n\r\nif __name__ == \"__main__\":\r\n\r\n gotham = City(name=\"Gotham\")\r\n batman = Hero(name=\"Batman\", city=gotham)\r\n\r\n assert batman.name == 'Batman' # This is fine\r\n assert batman.city == gotham # This now breaks\r\n```\r\n\r\n\r\n### Description\r\n\r\nOur CI suddenly started failing, despite local SQLModel working fine. The issues turns out to be the transitive dependency on SQLAlchemy, which is weakly pinned: Github Actions pulled the latest version (`1.4.36`) and most of our tests started failing.\r\n\r\nhttps://github.com/sqlalchemy/sqlalchemy/releases/tag/rel_1_4_36\r\n\r\nThe problem seems to be related to how relationships are defined, but I haven't yet dug into the SQLAlchemy changes enough to understand why that is.\r\n\r\nI'm opening this issue chiefly to help anybody else who is confused by why suddenly their tests are failing. I'm happy to help fix it if it's affecting others too. \r\n\r\nFor the time being we have just pinned `SQLAlchemy==1.4.34` in our `requirements.txt`.\r\n\r\n### Operating System\r\n\r\nLinux, macOS\r\n\r\n### Operating System Details\r\n\r\nReplicated locally and on Github Actions, both running in Docker\r\n\r\n### SQLModel Version\r\n\r\n0.0.6\r\n\r\n### Python Version\r\n\r\n3.9.10\r\n\r\n### Additional Context\r\n\r\nWe were previously running SQLAlchemy 1.4.34 locally and that works fine. Pinning to 1.4.36 breaks SQLModel.","author":{"url":"https://github.com/archydeberker","@type":"Person","name":"archydeberker"},"datePublished":"2022-04-27T15:24:19Z","url":"https://github.com/fastapi/sqlmodel/issues/315"}
| react-profiling | 0 |
| react-import-map | react,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-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:11b8e6fd-d708-202b-686b-26e899ae81eb |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9B84:2A5E57:16317E:1E7B59:6AFE0576 |
| html-safe-nonce | 4b17c27408c56c5d36cc00c024ee40d33805d6b2494981c4a62d22f5a780ec66 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5Qjg0OjJBNUU1NzoxNjMxN0U6MUU3QjU5OjZBRkUwNTc2IiwidmlzaXRvcl9pZCI6IjUwODkzOTY0Mzc3Nzk2MTMwNDYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 15b26198f1b4e1a5bbdbb9e103e8a1c394c60432f72d5f30fa57bb036556571f |
| hovercard-subject-tag | issue:1217515487 |
| 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/fastapi/sqlmodel/315/issue_layout |
| twitter:image | https://opengraph.githubassets.com/033a6d60d2e9d58513b1680115c04ec444bf37a635f745205eceb6c9ae137de4/fastapi/sqlmodel/issues/315 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/033a6d60d2e9d58513b1680115c04ec444bf37a635f745205eceb6c9ae137de4/fastapi/sqlmodel/issues/315 |
| og:image:alt | 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... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | archydeberker |
| hostname | github.com |
| expected-hostname | github.com |
| None | 86d46ece7c3d9b0562692f81a135cb55ad6a1c82c93ab1ac874d2f1b46b28958 |
| turbo-cache-control | no-preview |
| go-import | github.com/fastapi/sqlmodel git https://github.com/fastapi/sqlmodel.git |
| octolytics-dimension-user_id | 156354296 |
| octolytics-dimension-user_login | fastapi |
| octolytics-dimension-repository_id | 399495186 |
| octolytics-dimension-repository_nwo | fastapi/sqlmodel |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 399495186 |
| octolytics-dimension-repository_network_root_nwo | fastapi/sqlmodel |
| 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 | 5c18e6799976b7bc2f21178024289bb98edbcc85 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width