Open Ma233 opened 3 years ago
from sqlmodel import SQLModel, select, Column from sqlalchemy import UniqueConstraint from typing import List
class BookCollection(SQLModel, table=True): user_nid: int book_nid: int
uidx_book_collection = UniqueConstraint( Column("user_nid", Integer), # Specify the column type Column("book_nid", Integer), # Specify the column type name="uidx_book_collection_user_nid_book_nid" )
book_nids: List[int] = [1, 2, 3] query = select(BookCollection).where(BookCollection.booknid.in(book_nids))
print(uidx_book_collection) print(query)
First Check
Commit to Help
Example Code
Description
Some APIs of sqlalchemy may still need a column type. Without that, a type checker will complain. Currently, I'm using
type: ignore
to skip those.Operating System
Linux, macOS
Operating System Details
No response
SQLModel Version
0.0.4
Python Version
3.8.6
Additional Context
No response