René's URL Explorer Experiment


Title: Using hybrid_property of SQLAlchemy leads to CompileError · Issue #299 · fastapi/sqlmodel · GitHub

Open Graph Title: Using hybrid_property of SQLAlchemy leads to CompileError · Issue #299 · fastapi/sqlmodel

X Title: Using hybrid_property of SQLAlchemy leads to CompileError · Issue #299 · 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/299

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Using  hybrid_property of SQLAlchemy leads to CompileError","articleBody":"### First Check\n\n- [X] I added a very descriptive title to this issue.\n- [X] I used the GitHub search to find a similar issue and didn't find it.\n- [X] I searched the SQLModel documentation, with the integrated search.\n- [X] I already searched in Google \"How to X in SQLModel\" and didn't find any information.\n- [X] I already read and followed all the tutorial in the docs and didn't find an answer.\n- [X] I already checked if it is not related to SQLModel but to [Pydantic](https://github.com/samuelcolvin/pydantic).\n- [X] I already checked if it is not related to SQLModel but to [SQLAlchemy](https://github.com/sqlalchemy/sqlalchemy).\n\n### Commit to Help\n\n- [X] I commit to help with one of those options 👆\n\n### Example Code\n\n```python\nfrom sqlalchemy.ext.hybrid import hybrid_property  \r\nfrom typing import Optional  \r\nfrom sqlmodel import SQLModel, Field, create_engine  \r\n  \r\nfrom datetime import datetime  \r\n                                    \r\n                                      \r\nclass ObjectTable(SQLModel, table=True):  \r\n    object_id: Optional[int] = Field(primary_key=True, default=None)  \r\n    first_detection_time: datetime = Field(index=True)  \r\n    last_detection_time: datetime = Field(index=True)  \r\n      \r\n    @hybrid_property                                    \r\n    def detection_time(self) -\u003e float:  \r\n        return (self.last_detection_time - self.first_detection_time).total_seconds()  \r\n      \r\n    class Config:                 \r\n        arbitrary_types_allowed = True  \r\n                                                                                       \r\n     \r\nif __name__ == \"__main__\":  \r\n    engine = create_engine(\"sqlite:///database.db\")  \r\n    SQLModel.metadata.create_all(engine)\n```\n\n\n### Description\n\nI am trying to create a hybrid property in an SQLModel class to allow more complex querying. Following the steps as described in the sqlalchemy docs here: https://docs.sqlalchemy.org/en/14/orm/extensions/hybrid.html I assumed that this would work and create a valid table. However, this code gives the error:\r\n `sqlalchemy.exc.CompileError: (in table 'objecttable', column detection_time'): Can't generate DDL for NullType(); did you forget to specify a type on this Column?`\r\nAt first, I assumed that a type hint was missing so I added the `float` return type to the `hybrid_property`. I am not sure what the problem is exactly but I assumed that this code would yield a valid table.\n\n### Operating System\n\nLinux\n\n### Operating System Details\n\nUbuntu 20.04\n\n### SQLModel Version\n\n0.0.6\n\n### Python Version\n\nPython 3.8.10\n\n### Additional Context\n\n_No response_","author":{"url":"https://github.com/deZakelijke","@type":"Person","name":"deZakelijke"},"datePublished":"2022-04-14T11:27:07.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":13},"url":"https://github.com/299/sqlmodel/issues/299"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:8f37112f-34cf-f890-c11f-fc688c8ab0e4
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idDDD4:3EA203:8967BB:C1639F:6A624C54
html-safe-nonce9eadab35c0be2ce30f2825bb1138e46e8108e9c3492d861811a3d4426c57cddc
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEREQ0OjNFQTIwMzo4OTY3QkI6QzE2MzlGOjZBNjI0QzU0IiwidmlzaXRvcl9pZCI6Ijc5NDQ4ODc2NzE5NDAzMzY3MjQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac116d68536983a19de66c90855b874c6ecf01f62c34139bc66470b6a527efa359
hovercard-subject-tagissue:1204410009
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/299/issue_layout
twitter:imagehttps://opengraph.githubassets.com/67fff11b8558c7f8c8d0d3c7ca61b814b9f0623007b05aa0371442ddcf411f5b/fastapi/sqlmodel/issues/299
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/67fff11b8558c7f8c8d0d3c7ca61b814b9f0623007b05aa0371442ddcf411f5b/fastapi/sqlmodel/issues/299
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:usernamedeZakelijke
hostnamegithub.com
expected-hostnamegithub.com
None77f5af7d0fa3843b1779a53f60ec016b3f962e46051fb05c2e9b608a8138eefb
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
released3ce7d369aae307e197872f810f80f3ed9051c78
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/fastapi/sqlmodel/issues/299#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Ffastapi%2Fsqlmodel%2Fissues%2F299
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
Code QualityEnforce quality at mergehttps://github.com/features/code-quality
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
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
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://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
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Ffastapi%2Fsqlmodel%2Fissues%2F299
Sign up https://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/299
Reloadhttps://github.com/fastapi/sqlmodel/issues/299
Reloadhttps://github.com/fastapi/sqlmodel/issues/299
Please reload this pagehttps://github.com/fastapi/sqlmodel/issues/299
fastapi https://github.com/fastapi
sqlmodelhttps://github.com/fastapi/sqlmodel
Please reload this pagehttps://github.com/fastapi/sqlmodel/issues/299
Notifications https://github.com/login?return_to=%2Ffastapi%2Fsqlmodel
Fork 874 https://github.com/login?return_to=%2Ffastapi%2Fsqlmodel
Star 18.2k https://github.com/login?return_to=%2Ffastapi%2Fsqlmodel
Code https://github.com/fastapi/sqlmodel
Issues 1 https://github.com/fastapi/sqlmodel/issues
Pull requests 58 https://github.com/fastapi/sqlmodel/pulls
Discussions https://github.com/fastapi/sqlmodel/discussions
Actions https://github.com/fastapi/sqlmodel/actions
Projects https://github.com/fastapi/sqlmodel/projects
Security and quality 0 https://github.com/fastapi/sqlmodel/security
Insights https://github.com/fastapi/sqlmodel/pulse
Code https://github.com/fastapi/sqlmodel
Issues https://github.com/fastapi/sqlmodel/issues
Pull requests https://github.com/fastapi/sqlmodel/pulls
Discussions https://github.com/fastapi/sqlmodel/discussions
Actions https://github.com/fastapi/sqlmodel/actions
Projects https://github.com/fastapi/sqlmodel/projects
Security and quality https://github.com/fastapi/sqlmodel/security
Insights https://github.com/fastapi/sqlmodel/pulse
Using hybrid_property of SQLAlchemy leads to CompileErrorhttps://github.com/fastapi/sqlmodel/issues/299#top
investigatehttps://github.com/fastapi/sqlmodel/issues?q=state%3Aopen%20label%3A%22investigate%22
questionFurther information is requestedhttps://github.com/fastapi/sqlmodel/issues?q=state%3Aopen%20label%3A%22question%22
https://github.com/deZakelijke
deZakelijkehttps://github.com/deZakelijke
on Apr 14, 2022https://github.com/fastapi/sqlmodel/issues/299#issue-1204410009
Pydantichttps://github.com/samuelcolvin/pydantic
SQLAlchemyhttps://github.com/sqlalchemy/sqlalchemy
https://docs.sqlalchemy.org/en/14/orm/extensions/hybrid.htmlhttps://docs.sqlalchemy.org/en/14/orm/extensions/hybrid.html
investigatehttps://github.com/fastapi/sqlmodel/issues?q=state%3Aopen%20label%3A%22investigate%22
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.