Intellisense autocomplete does not show for in_
in VSCode
#1477
-
First Check
Commit to Help
Example Codefrom typing import Optional
from sqlmodel import Field, Session, SQLModel, create_engine, select
class Hero(SQLModel, table=True):
id: Optional[int] = Field(default=None, primary_key=True)
name: str
secret_name: str
age: Optional[int] = None
hero_1 = Hero(name="Deadpond", secret_name="Dive Wilson")
hero_2 = Hero(name="Beep", secret_name="B")
engine = create_engine("sqlite:///database.db", echo=True)
SQLModel.metadata.create_all(engine)
with Session(engine) as session:
session.add(hero_1)
session.add(hero_2)
session.commit()
session.refresh(hero_1)
session.refresh(hero_2)
print(f"{hero_1=}")
print(f"{hero_2=}")
hero_names = [
"Beep",
"Boop",
"Deadpond",
"Zorf",
]
db_statement = select(Hero).where(Hero.name.in_(hero_names))
db_data = session.exec(db_statement).all()
print(f"{db_data=}") Description
Operating SystemmacOS Operating System DetailsNo response SQLModel Version0.0.4 Python Version3.10.2 Additional ContextI do have a fair number of VSCode extensions, but I don't think that is the issue, since I do get autocomplete for everything else from |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
I guess this is because |
Beta Was this translation helpful? Give feedback.
-
from sqlmodel import col
db_statement = select(Hero).where(col(Hero.name).in_(hero_names)) |
Beta Was this translation helpful? Give feedback.
-
Still have error: |
Beta Was this translation helpful? Give feedback.
sqlmodel
provides a functioncol()
to changeSQLModel attrs
toColumn
, so you just need to change your code like this: