Skip to content

Intellisense autocomplete does not show for in_ in VSCode #294

@taranlu-houzz

Description

@taranlu-houzz

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 IN clause, I noticed that VSCode intellisense does not show an autocomplete option for the in_() 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, the in_ function does not show up.
  • This really confused me, because I am new to slqmodel and slqalchemy, and I was trying to figure out how to generate an IN clause.
  • The sqlmodel documentation 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions