-
Notifications
You must be signed in to change notification settings - Fork 906
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
ValueError when executing queries #701
Comments
I'm also encountering this issue, but it's 100% reproducible for me. I have a "sessiondata" table and a "videodata" table, videodata contains a FK reference to a sessiondata PK id. A GET to following URL pattern will always give me a ValueError: patterns = ['/sessiondata/session_uuid/{sessiondata.session_uuid}/videos[videodata.session_id]'] #All entries from the video table matching session uuid
## e.g. http://127.0.0.1:8000/api/sessiondata/session_uuid/TESTTEST00004000A0003000000000001/videos
(The result of the above query is actually id=4 session_uuid=TESTTEST00004000A0003000000000001 so the rows being requested do exist and there isn't anything wrong with the SQL.) It seems that the DAL has somehow lost it's connection (it gets set to None) before completing the join. Other, more simple queries like /sessiondata/session_uuid/{sessiondata.session_uuid}/ evaluate fine. Web2Py version: 2.9.11-stable+timestamp.2014.09.15.23.35.11 db = DAL('sqlite://storage.sqlite',pool_size=10,check_reserved=['all']) Like @niphlod , I've spent about 2 days trying to figure out what is happening. This is just a simple FK join, so how can I make it work? |
I have absolutely the same issue with 2.9.12-stable+timestamp.2015.01.17.06.11.03 I create connection like:
and use current.db everywhere including modules. Thanks. My bad. |
IMHO this has been fixed, and is closely related on how people misuse the DAL object in their apps. Until further notices by @pi-aej for 2.9.12, I'd close this. |
ok, closing in absence of further notices |
In my case it was caused by usage of DAL object in current on module level (to avoid writing current.db instead of db all the time):
As far as I understand this is what happened: While accessing db in current inside the function retrieves actual value at each call and everything goes fine. Just for others googling the cause of such issue. |
From buzypi on March 20, 2014 17:15:23
Here is how my various files look:
models/db.py:
from gluon import current
db = DAL('%s://%s:%s__at__%s/%s' % (...))
current.db = db
modules/modelmanager.py:
class ModelManager:
def init(self):
self.db = current.db
In the end of this module I have a singleton instance of this class
which I intend to use in a bunch of places
mmanager = ModelManager()
controllers/mycontroller.py
from modelmanager import mmanager
def foo():
db_data = mmanager.get_something_from_db(...)
Every once in a while I see this error:
File "/var/deploy/jnaapti/web2py/gluon/dal.py", line 1956, in log_execute
if not self.connection: raise ValueError(a[0])
ValueError:
My questions are:
Linux dev 3.2.0-58-generic-pae
#88
-Ubuntu SMP Tue Dec 3 18:00:02 UTC 2013 i686 i686 i386 GNU/LinuxVersion 2.9.5-stable+timestamp.2014.03.16.02.35.39 Please provide any additional information below. What is the right way of moving common model code to a separate module?
Original issue: http://code.google.com/p/web2py/issues/detail?id=1905
The text was updated successfully, but these errors were encountered: