Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Make generics work with SQLModel as base class #1275

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

ryangalamb
Copy link

Generics, as documented in pydantic's docs do not work.

Repro: Use the example from pydantic's docs. The typevar type does not get validated.

For example: Response[int](data="not an int") does not raise an error.

Furthermore, json schema generation is broken, as described here: #1002

This PR:

  • fixes generics, so they actually validate (instead of silently passing)
  • includes thorough tests (based on an example from pydantic's docs)

@ryangalamb
Copy link
Author

ryangalamb commented Jan 24, 2025

(I broke the pydantic v1 tests because I added a test and forgot to label it as v2 only. I will fix it when I get back to my computer.)

Fixed. Once #1276 is merged, all this PR's tests should pass.

@svlandeg svlandeg added the feature New feature or request label Feb 20, 2025
@svlandeg svlandeg added bug Something isn't working and removed feature New feature or request labels Feb 20, 2025
@svlandeg svlandeg changed the title fix: make generics work with SQLModel as base class 🐛 Make generics work with SQLModel as base class Feb 20, 2025
@svlandeg
Copy link
Member

Thanks for the contribution! We're currently trying to catch up with the backlog of PRs, and will get back to you once we've had time to review this 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants