Open
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 Any, List
from fastapi import APIRouter, Depends
from sqlmodel import Session, select, text, SQLModel
from pydantic import BaseModel
from app.api.deps import get_session_legacy
router = APIRouter(prefix="/")
class Test(BaseModel):
hello: str
@router.get("/data", response_model=List[Test])
async def get_data(
db: Session = Depends(get_session_legacy)
):
sql = text(
"""
SELECT 'hi' AS "hello"
"""
)
result = db.exec(sql).all()
for res in result:
logger.info(f"response: {res}")
return result
Description
When using db.exec(select(Hero))
you can use auto-suggestion in vscode to see the methods that belong to exec().
However when using db.exec(text("SELECT * FROM hero"))
then there are no suggestions following the exec().
Wanted Solution
I want to see the suggestions: db.exec(text()).[one(), all(), scalars(), etc...]
Wanted Code
from typing import Any, List
from fastapi import APIRouter, Depends
from sqlmodel import Session, select, text, SQLModel
from pydantic import BaseModel
from app.api.deps import get_session_legacy
router = APIRouter(prefix="/")
class Test(BaseModel):
hello: str
@router.get("/data", response_model=List[Test])
async def get_data(
db: Session = Depends(get_session_legacy)
):
sql = text(
"""
SELECT 'hi' AS "hello"
"""
)
result = db.exec(sql).[all(), one(), scallars()... etc]
for res in result:
logger.info(f"response: {res}")
return result
Alternatives
No response
Operating System
Linux
Operating System Details
wsl2 on windows, vscode
SQLModel Version
0.0.6
Python Version
3.10
Additional Context
No response