Skip to content

TypeError: issubclass() arg 1 must be a class when having a field with a complex type #1522

Discussion options

You must be logged in to vote

You need to specify the column type for SQLAlchemy (Field(sa_type=JSON) in this case):

    semantic_search_result: List[Tuple[int, Dict[str, Union[str, int, float]]]] = Field(
        sa_type=JSON
    )

Runnable code example in the details:

from typing import Dict, List, Optional, Tuple, Union

from sqlmodel import JSON, Field, Session, SQLModel, create_engine


class SemanticSearch(SQLModel, table=True):
    id: Optional[int] = Field(default=None, primary_key=True)
    ...
    semantic_search_result: List[Tuple[int, Dict[str, Union[str, int, float]]]] = Field(
        sa_type=JSON
    )


## sqlite
sqlite_url = "sqlite:///"
engine = create_engine(sqlite_url, echo=True)


def main():
    S…

Replies: 10 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by YuriiMotov
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
10 participants
Converted from issue

This discussion was converted from issue #67 on August 15, 2025 06:51.