sqlmodel icon indicating copy to clipboard operation
sqlmodel copied to clipboard

✨ Add PEP 593 support for Requirement annotations

Open bolu61 opened this issue 1 year ago • 6 comments

see https://github.com/fastapi/sqlmodel/issues/229#issuecomment-2132852311

I'm not really sure how Pydantic does it, but here's a potential workaround to the problem.

bolu61 avatar Oct 29 '24 22:10 bolu61

@YuriiMotov I agree.

I'm not too familiar with this codebase. Can you point me to where I can write those tests?

bolu61 avatar Sep 11 '25 14:09 bolu61

I'm not too familiar with this codebase. Can you point me to where I can write those tests?

You can create an annotated version of the code example from "Relationships" section of docs:

  • Go to https://github.com/fastapi/sqlmodel/tree/main/docs_src/tutorial/relationship_attributes/define_relationship_attributes
  • Create a copy of tutorial001_py310.py, call it tutorial001_an_py310.py
  • Edit code to follow the Annotated approach
  • Go to https://github.com/fastapi/sqlmodel/tree/main/tests/test_tutorial/test_relationship_attributes/test_define_relationship_attributes
  • Create a copy of test_tutorial001_py310.py, call it test_tutorial001_an_py310.py
  • Update code to import app from tutorial001_an_py310.py
  • Push changes and check that new version of code example appeared in "Other versions and variants"

YuriiMotov avatar Oct 07 '25 18:10 YuriiMotov

Heads-up: this will be closed in 3 days unless there’s new activity.

github-actions[bot] avatar Nov 04 '25 18:11 github-actions[bot]

The test is failing with:

FAILED tests/test_tutorial/test_relationship_attributes/test_define_relationship_attributes/test_tutorial001_an_py310.py::test_tutorial - sqlalchemy.exc.ArgumentError: Mapper Mapper[Team(team)] could not assemble any primary key columns for mapped table 'team'

I'm not exactly sure how to approach this.

bolu61 avatar Nov 07 '25 00:11 bolu61

📝 Docs preview

Last commit 40af6901b885c2c80b164ca3c11c96c29f32d805 at: https://c0d7bffc.sqlmodel.pages.dev

github-actions[bot] avatar Nov 07 '25 00:11 github-actions[bot]

The test is failing with:

FAILED tests/test_tutorial/test_relationship_attributes/test_define_relationship_attributes/test_tutorial001_an_py310.py::test_tutorial - sqlalchemy.exc.ArgumentError: Mapper Mapper[Team(team)] could not assemble any primary key columns for mapped table 'team'

I'm not exactly sure how to approach this.

This is related to https://github.com/fastapi/sqlmodel/issues/1623 . I hope it will be fixed soon

YuriiMotov avatar Nov 07 '25 07:11 YuriiMotov