-
-
Notifications
You must be signed in to change notification settings - Fork 792
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 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
- When trying to figure out how to generate a proper
INclause, I noticed that VSCode intellisense does not show an autocomplete option for thein_()function on a model field (although it does still appear to work as expected). - In the example code I posted, when I type:
Hero.name.i, thein_function does not show up. - This really confused me, because I am new to
slqmodelandslqalchemy, and I was trying to figure out how to generate anINclause. - The
sqlmodeldocumentation also does not mention how to do this currently. I think it might be a good idea to add, since it is such a common use case.
Operating System
macOS
Operating System Details
No response
SQLModel Version
0.0.4
Python Version
3.10.2
Additional Context
I 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 sqlmodel.
bbuschkaemper
Metadata
Metadata
Assignees
Labels
questionFurther information is requestedFurther information is requested