Title: Different response model behaviour on Mac vs Ubuntu when joining tables · Issue #379 · fastapi/sqlmodel · GitHub
Open Graph Title: Different response model behaviour on Mac vs Ubuntu when joining tables · Issue #379 · fastapi/sqlmodel
X Title: Different response model behaviour on Mac vs Ubuntu when joining tables · Issue #379 · 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/379
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Different response model behaviour on Mac vs Ubuntu when joining tables","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\n# Example interleaved with the description\r\n```\r\n\r\n\r\n### Description\r\n\r\nI have these models:\r\n\r\n```python\r\nclass SourceBase(SQLModel):\r\n name: str = Field(nullable=False)\r\n url: str = Field(nullable=False, sa_column_kwargs={\"unique\": True})\r\n\r\n\r\nclass Source(SourceBase, table=True):\r\n id: Optional[int] = Field(default=None, primary_key=True)\r\n users: List[\"User\"] = Relationship(back_populates=\"sources\", link_model=UserSourceLink)\r\n articles: List[\"Article\"] = Relationship(back_populates=\"source\")\r\n\r\n\r\nclass SourceGet(SourceBase):\r\n id: int\r\n\r\n\r\nclass ArticleBase(SQLModel):\r\n title: str = Field(nullable=False)\r\n url: str = Field(nullable=False, sa_column_kwargs={\"unique\": True})\r\n published_date: str = Field(nullable=False)\r\n read: bool = Field(default=False, nullable=False)\r\n source_id: Optional[int] = Field(default=None, foreign_key=\"source.id\")\r\n\r\n\r\nclass Article(ArticleBase, table=True):\r\n id: Optional[int] = Field(default=None, primary_key=True)\r\n source: Source = Relationship(back_populates=\"articles\")\r\n\r\n\r\nclass ArticleRead(ArticleBase):\r\n id: int\r\n\r\nclass ArticleReadWithSource(ArticleGet):\r\n source: Optional[SourceGet] = None\r\n```\r\n\r\nI have a function that selects all rows from the article table: \r\n\r\n```python\r\ndef select_all_articles(offset, limit, session: Session) -> List:\r\n statement = select(Article).order_by(Article.published_date.desc()).offset(offset).limit(limit)\r\n results = session.exec(statement).all()\r\n return results\r\n```\r\n\r\nI have another function which returns these rows along with the source to which they get joined:\r\n\r\n```python\r\n@router.get(\"/\", response_model=List[ArticleReadWithSource])\r\ndef get_all_articles(\r\n offset: int = 0,\r\n limit: int = Query(default=100, lte=100),\r\n session: Session = Depends(db.get_session),\r\n current_user: User = Depends(get_current_user),\r\n) -> List:\r\n articles = db.select_all_articles(offset, limit, session)\r\n return articles\r\n```\r\n\r\nThis works perfectly on my local machine (macOS Montery):\r\n\r\n\r\nHowever, when running this same code on a remote Ubuntu 20.04 machine, the join seems to silently fail and the source object is returned as a `null` \r\n\r\n\r\nHas anyone ever seen any behaviour like this? The code is identical on each machine so I'm struggling to think of ways to debug this\r\n\r\n### Operating System\r\n\r\nLinux\r\n\r\n### Operating System Details\r\n\r\n_No response_\r\n\r\n### SQLModel Version\r\n\r\n0.06\r\n\r\n### Python Version\r\n\r\n3.10.5\r\n\r\n### Additional Context\r\n\r\n_No response_","author":{"url":"https://github.com/HenryDashwood","@type":"Person","name":"HenryDashwood"},"datePublished":"2022-07-17T17:08:51Z","url":"https://github.com/fastapi/sqlmodel/issues/379"}
| 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:508b331d-0c6d-b3e1-ddf0-a27dceeb1a10 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AE50:1E492C:1BAB00:25D2FD:6AFE17C7 |
| html-safe-nonce | 3086ae11cd7a23046c24f99db13aec45958c3f0bfaf8cd76fdfcc9244a53f384 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRTUwOjFFNDkyQzoxQkFCMDA6MjVEMkZEOjZBRkUxN0M3IiwidmlzaXRvcl9pZCI6IjgwMjQ1MDIwNDE5MDI0NTQ3MjciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | d2af4793f9e9b5e8e0597a1096b3f932602fbe278615eeaa71a54c8aaf454e03 |
| hovercard-subject-tag | issue:1307158163 |
| 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/379/issue_layout |
| twitter:image | https://opengraph.githubassets.com/5b50817899c465ee58f7abb342d20f13712e34ef2c892fa840726774be39ec78/fastapi/sqlmodel/issues/379 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/5b50817899c465ee58f7abb342d20f13712e34ef2c892fa840726774be39ec78/fastapi/sqlmodel/issues/379 |
| 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 | HenryDashwood |
| hostname | github.com |
| expected-hostname | github.com |
| None | 3cd8a1d79ccbf9aecac62781f79072482a49047fb982b8c9e2ad4aca8bf6a9af |
| 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 | 05539640a34afe6142a519483d78ddd766a1304a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width