New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SAWarning from sqlalchemy #189
Comments
I've solved mine by importing select() from sqlalchemy directly. |
Be aware that if you select a single value, you will still get a tuple in return, e.g.: # with 'select' from sqlmodel
with Session(engine) as session:
count_statement = select(func.count()).select_from(Book).where(Book.release_year < 1960)
amount = session.exec(count_statement).first()
assert amount == 2 This needs to be |
Is importing select() from sqlalchemy really a solution to this, it don't see the point of using SQLModel and then bypassing it on all select statements. ? Is there a parameter/settings that need to be set somewhere to activating the caching ? |
While i can't tell you why, the following amendment resolves this warning for me: # raises the SAWarning
session.query(MyModel).where(MyModel.field1 == 'value').first()
# Does not raise the warning
from sqlmodel import col
session.query(MyModel).where(col(MyModel.field1) == 'value').first() |
…messages fortunately nothing broke except for a warning tiangolo/sqlmodel#189 Signed-off-by: Pratik Gorade <me@prkprime.dev>
Did you find an answer?
What happens when you don't need a with Session(engine) as session:
stmt = select(MyModel)
results = session.exec(stmt).all() |
I haven't found any way to disable caching for now. |
I am having the same issue. Fix needed ASAP. |
Same issue |
Same here :) |
Same issue... |
Hi everyone, please stop replying with "same" without contributing more info, that is what the 👍 button at the top is for. Doing so generates spam for everyone who is subscribed, and wastes the valuable time of people like tiangolo. Using the 👍 button in this way is generally considered good etiquette across all of GitHub. Thanks, and I also hope that someone comes up with a solution soon. 😃 EDIT: LOL, what is going on here? Is this GitHub or Facebook? I'm not sure whether or not @mmlynarik is trolling. 😂 I'm just subscribed to this thread, hoping for a solution, and getting mildly disappointed each time I receive a notification for a pointless message. I'm not particularly motivated to try and solve this issue myself. I do however have a suggestion... If you are so eager for tiangolo to fix this issue, then rather than spamming him, please consider showing him some ❤️ with the Sponsor button at the bottom. I'd really love to see FOSS maintainer become a more viable career choice. |
@maresb do you know what is the reason for the warning? Maybe @tiangolo could drop here some hint what could have gone wrong... |
You can check the list of sponsors, you will find my name on it. |
Not a long term solution, but if you want to filter out the error for now you can use the following snippet: import warnings
warnings.filterwarnings("ignore", ".*Class SelectOfScalar will not make use of SQL compilation caching.*") |
I would be happy to set the mentioned attribute Following the link in the error, https://sqlalche.me/e/14/cprf, gives some background, but no instruction on where or how to set the attribute. |
The solution I found was that the Personally, while it is fixed, I will set that field in my code in the following way. from sqlmodel.sql.expression import Select, SelectOfScalar
SelectOfScalar.inherit_cache = True # type: ignore
Select.inherit_cache = True # type: ignore |
Just a friendly ping to @tiangolo. |
Refer to tiangolo/sqlmodel#189 for more info
ModuleNotFoundError: No module named 'sqlmodel' Does anyone have an actual solution? I tried to install the dependency myself, but this does not lead to a solution, then I gave the opportunity to install PyCharm but the result is the same |
### Fixed * Workaround for SAWarcning in SQLModel (discussed here: tiangolo/sqlmodel#189) * Handle missing status detail when analysis is not paired
have effect side, [{'a': {}}] |
See: tiangolo#189 Signed-off-by: Javier Marcet <javier.marcet@bigblueanalytics.com>
Thanks for the report! This was solved in #234, it will be available in SQLModel If some of you would like to help me maintain SQLModel, it would be much appreciated! What I need help with the most is answering questions from others in issues. Thanks! 🍰 |
I just upgraded to SQLModel |
It seems the fix was only applied to |
I had only changed the jinja one due to this line at the top of the python file. |
I guess that makes sense. I have no idea how exactly the release works here. It looks to me like generate_select.py was supposed to have been executed at some point but wasn't. |
Ah! Thanks everyone, good point @rabinadk1, I fixed it in #422, I also made a test that ensures the file is up to date with the Jinja2 template. This will be available in the next version, in some hours. SQLModel |
Can this be closed? |
@nickatnight Yes, this is now working as expected. The warning is no longer shown. |
First Check
Commit to Help
Example Code
Description
Every time I use the SQLModel ORM, I get this warning.
A link is given.
Operating System
Linux
Operating System Details
Linux 5.15.7-arch1-1 x86_64 GNU/Linux
SQLModel Version
0.0.4
Python Version
Python 3.9.9
Additional Context
The only other reference to this problem that I have found is this one
#129 (comment)
The text was updated successfully, but these errors were encountered: