SQLModel columns are flagged when a database function is called onto them
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 516
- PR merge metrics
- No merged PRs in 30d
Description
### Describe the Bug
Let's build a database and put some rows into it:
```
from sqlmodel import Field, Session, SQLModel, create_engine, select
class Hero(SQLModel, table=True):
id: int | None = Field(default=None, primary_key=True)
name: str
secret_name: str
age: int | None = None
hero_1 = Hero(name="Deadpond", secret_name="Dive Wilson")
hero_2 = Hero(name="Spider-Boy", secret_name="Pedro Parqueador")
hero_3 = Hero(name="Spider-Boy", secret_name="Tommy Sharp", age=48)
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.add(hero_3)
session.commit()
# We now retrieve the IDs of the rows with `name=="Spider-Boy"` in decreasing order:
with Session(engine) as session:
statement = select(Hero.id).where(Hero.name == "Spider-Boy").order_by(Hero.id.desc())
hero = session.exec(statement).all()
print(hero)
```
The problem is that `pyrefly` flags `Hero.id.desc()` because it thinks that `Hero.id` is typed `int | None` and thus has no `desc` function:
### Sandbox Link
_No response_
### (Only applicable for extension issues) IDE Information
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.