Skip to content

Conversation

@svlandeg
Copy link
Member

@svlandeg svlandeg commented Feb 2, 2026

Reconstructing PR #1439, as the original author has closed this PR but @YuriiMotov and I had actually spent quite a bit of time on this already (in fact, we had completely rewritten the PR at this point 🙈).

Let me recap the history:

  • Originally the PR was created to fix #57, i.e. ensure there is no crash when using a Literal type annotation with SQLModel.
  • The PR assumed that all Literal values were strings (thus creating a DB column with type string), which @tiangolo pointed out wouldn't be ideal because it would be unexpected for input like Literal[1, 2, 3].
  • Yurii then added some detection logic for all-int and all-bool cases, to at least set the DB column type correctly. But he also raised the question of data validation.
  • I then pushed another update to create SQL constraints for the values in the Literal. This way, the data can't get corrupted and the user won't receive values that don't match the expected Literal definition.
  • The question of having mixed types is still open-ended, we can resolve it by either (1) making all str as "best attempt", (2) reject the input entirely or (3) some other way I'm not seeing.

@svlandeg svlandeg added the feature New feature or request label Feb 2, 2026
@svlandeg svlandeg assigned svlandeg and unassigned svlandeg Feb 2, 2026
@svlandeg svlandeg marked this pull request as ready for review February 2, 2026 09:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Variables with annotation of 'typing.Literal' causes a panic

1 participant