-
-
Notifications
You must be signed in to change notification settings - Fork 812
Closed
Labels
questionFurther information is requestedFurther information is requested
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 SQLModel" and didn't find any information.
- I already read and followed all the tutorial in the docs and didn't find an answer.
- I already checked if it is not related to SQLModel but to Pydantic.
- I already checked if it is not related to SQLModel but to SQLAlchemy.
Commit to Help
- I commit to help with one of those options 👆
Example Code
from datetime import date
from typing import Optional, Union
from sqlmodel import SQLModel
class Person(SQLModel):
name: str
birthdate: Optional[Union[date, str]]
....Description
I want to store information about some people in a MySQL database. Due to the nature of the information, birth dates can be full dates (1940-05-02), month and year (1932-07) or years only (1965). I searched the pydantic documentation and it says to use Unions to accept multiple data types. However, when I try to do this sqlmodel raises the error TypeError: issubclass() arg 1 must be a class. I know the issue comes from union because if I remove it then the code works just fine.
Operating System
Windows
Operating System Details
No response
SQLModel Version
0.0.6
Python Version
3.10.2
Additional Context
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
questionFurther information is requestedFurther information is requested