question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AttributeError after upgrading to 1.3.13

See original GitHub issue

I don’t know if this somehow affects the problem, but I use Flask-SQLAlchemy.

The part of code is as follows:

note = Note.query.options(noload('*')).with_for_update(of=Note).get_or_404(note_id)
db.session.refresh(note)

After upgrading SQLAlchemy version from 1.3.12 to 1.3.13 I got the following exception traceback:

  File " /home/decaz/workspace/project/views.py", line 432, in post                                                                                                                 
    db.session.refresh(note)                                                                                                                                                                                                                                                      
  File " /home/decaz/workspace/project/.venv/lib/python3.8/site-packages/sqlalchemy/orm/scoping.py", line 162, in do                                                                                                                                                            
    return getattr(self.registry(), name)(*args, **kwargs)                                                                       
  File " /home/decaz/workspace/project/.venv/lib/python3.8/site-packages/sqlalchemy/orm/session.py", line 1675, in refresh                                                                                                                                                      
    loading.load_on_ident(                                                                                                    
  File " /home/decaz/workspace/project/.venv/lib/python3.8/site-packages/sqlalchemy/orm/loading.py", line 198, in load_on_ident                                                                                  
    return load_on_pk_identity(                                                                                                                                 
  File " /home/decaz/workspace/project/.venv/lib/python3.8/site-packages/sqlalchemy/orm/loading.py", line 284, in load_on_pk_identity
    return q.one()                                                                                                                        
  File " /home/decaz/workspace/project/.venv/lib/python3.8/site-packages/sqlalchemy/orm/query.py", line 3347, in one                                                                                               
    ret = self.one_or_none()                                                                                                        
  File " /home/decaz/workspace/project/.venv/lib/python3.8/site-packages/sqlalchemy/orm/query.py", line 3316, in one_or_none                          
    ret = list(self)                                                                                                                  
  File " /home/decaz/workspace/project/.venv/lib/python3.8/site-packages/sqlalchemy/orm/loading.py", line 101, in instances         
    util.raise_from_cause(err)                                                                                            
  File " /home/decaz/workspace/project/.venv/lib/python3.8/site-packages/sqlalchemy/util/compat.py", line 398, in raise_from_cause
    reraise(type(exception), exception, tb=exc_tb, cause=cause)                                                                                                                                                                                               
  File " /home/decaz/workspace/project/.venv/lib/python3.8/site-packages/sqlalchemy/util/compat.py", line 153, in reraise                                                                           
    raise value                                                                                                                                                                                                                           
  File " /home/decaz/workspace/project/.venv/lib/python3.8/site-packages/sqlalchemy/orm/loading.py", line 81, in instances                                                              
    rows = [proc(row) for row in fetch]                                                                                                                                                                            
  File " /home/decaz/workspace/project/.venv/lib/python3.8/site-packages/sqlalchemy/orm/loading.py", line 81, in <listcomp>
    rows = [proc(row) for row in fetch]                                                                                                        
  File " /home/decaz/workspace/project/.venv/lib/python3.8/site-packages/sqlalchemy/orm/loading.py", line 565, in _instance                           
    _populate_full(                                                                                                                                                                                     
  File " /home/decaz/workspace/project/.venv/lib/python3.8/site-packages/sqlalchemy/orm/loading.py", line 730, in _populate_full                      
    populator(state, dict_, row)                                                                                                       
  File " /home/decaz/workspace/project/.venv/lib/python3.8/site-packages/sqlalchemy/orm/strategies.py", line 2031, in load_collection_from_joined_existing_row                                      
    inst = _instance(row)                                                                                                                                                                             
  File " /home/decaz/workspace/project/.venv/lib/python3.8/site-packages/sqlalchemy/orm/loading.py", line 565, in _instance                                                                         
    _populate_full(                                                                                                                                                                                   
  File " /home/decaz/workspace/project/.venv/lib/python3.8/site-packages/sqlalchemy/orm/loading.py", line 709, in _populate_full
    elif load_path != state.load_path:
  File " /home/decaz/workspace/project/.venv/lib/python3.8/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'

@zzzeek unfortunately, right now I don’t have time to prepare an example that reproduces the problem, but I hope you’ll be able to understand what is the reason.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
zzzeekcommented, Jan 22, 2020

OK so I really do not want to encourage bug reports like these. the stack trace is helpful but if you can at least share the mappings, that will save me a lot of time. This is reproducible as I stepped through the stack trace and attempted to reproduce the conditions at each step and I then got a bit lucky on a few guesses. here is the test case, bisection coming next.

from sqlalchemy import Column
from sqlalchemy import create_engine
from sqlalchemy import ForeignKey
from sqlalchemy import Integer
from sqlalchemy import String
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import lazyload
from sqlalchemy.orm import relationship
from sqlalchemy.orm import Session

Base = declarative_base()


class A(Base):
    __tablename__ = "a"

    id = Column(Integer, primary_key=True)
    data = Column(String)
    bs = relationship("B", lazy="joined")


class B(Base):
    __tablename__ = "b"
    id = Column(Integer, primary_key=True)
    a_id = Column(ForeignKey("a.id"))
    data = Column(String)
    c_id = Column(ForeignKey("c.id"))
    cs = relationship("C", lazy="joined")


class C(Base):
    __tablename__ = "c"
    id = Column(Integer, primary_key=True)


e = create_engine("sqlite://", echo=True)
Base.metadata.create_all(e)

s = Session(e)

c1 = C()
s.add(A(bs=[B(cs=c1), B(cs=c1)]))
s.commit()
a1 = s.query(A).options(lazyload(A.bs).lazyload(B.cs)).get(1)
s.refresh(a1)


0reactions
ozamani9commented, Feb 10, 2020

Thank you. I misinterpreted sqlalchemy-bot closed this in f5eeac3 19 days ago as being fixed in 1.3.13. Thank you for the clarification.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Django - installing mysqlclient error: mysqlclient 1.3.13 or ...
Go to your django/db/backends/mysql installation dir. Check your path in the error message. I'm using pipenv so my path is: /home/username/ ...
Read more >
AttributeError: 'EntryPoint' object has no attribute '_key', stops ...
After a while the computation stops with the message AttributeError: 'EntryPoint' object has no attribute '_key .
Read more >
AttributeError: 'module' object has no attribute and ImportError
This video covers the AttributeError : 'module' object has no attribute and ImportError: No module name errors in Python.
Read more >
AttributeError: module 'natsort' has no attribute 'compat'
After installing the new env, it gave me this following error: Mac OS X: ValueError: unknown locale: UTF-8 in Python that I fixed...
Read more >
Attribute Error while using networkx ... - Google Groups
write_gpickle(<filename>). I retrieved these graphs in another of my python programs using networkx.read_gpickle(<filename>,<format type>). Then I try ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found