Exception on '.refresh' for certain objects - state.load_path Tuple is empty

23 views
Skip to first unread message

Gmoney

unread,
Mar 8, 2021, 1:09:57 PM3/8/21
to sqlalchemy
On python 3.7 SQLAlchemy 1.3.13
I'm running into an issue when doing a session.refresh(orm_object) where for certain objects it throws an exception because in line 709 of orm/loading.py, the 'state.load_path' is an empty tuple.  Attached the relevant snippet of the stack dump below.

This was simple test with no actual changes:  
task = Task.query.filter(blah).one()
session.refresh(task)
Again it works for some, not for others.

Is there was something obvious that might cause this - perhaps I'm misunderstanding how refresh works?  We have numerous relationships on the model that often refer to the same table (multiple 'user_id' fk references).  This hasn't causes us any other issues, but it's worth noting.

I will try to pare down the model to isolate what the cause is, and follow up with a test case if I can.  But wanted to see if it was anything obvious before I dig too deep.

  File "/-/lib/python3.7/site-packages/sqlalchemy/orm/loading.py", line 709, in _populate_full

    elif load_path != state.load_path:

  File "-/lib/python3.7/site-packages/sqlalchemy/orm/path_registry.py", line 63, in __eq__

    return other is not None and self.path == other.path

AttributeError: 'tuple' object has no attribute 'path'

 



Mike Bayer

unread,
Mar 8, 2021, 4:38:13 PM3/8/21
to noreply-spamdigest via sqlalchemy
it looks like a bug unless you are manipulating the InstanceState.   I would upgrade to SQLAlchemy 1.3.23 first to make sure it hasn't been fixed.
--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
 
 
To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description.
---
You received this message because you are subscribed to the Google Groups "sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+...@googlegroups.com.

Gmoney

unread,
Mar 8, 2021, 6:44:00 PM3/8/21
to sqlalchemy
Looks like that did the trick!  Should have tried that first, but got lazy when conda was resisting my update attempts earlier.
Thank you

Mike Bayer

unread,
Mar 9, 2021, 9:26:16 AM3/9/21
to noreply-spamdigest via sqlalchemy
still kind of weird, I am not seeing any issue like this that was fixed, wouldn't mind seeing a reproducer case but no worries.
Reply all
Reply to author
Forward
0 new messages