- edited description
- changed title to _mapper_info() fails if non-mapper entity
- marked as bug
_mapper_info() fails if non-mapper entity
Issue #3836
resolved
this is a 1.1 regression:
from sqlalchemy import *
from sqlalchemy.orm import *
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
class A(Base):
__tablename__ = 'a'
id = Column(Integer, primary_key=True)
x = Column(Integer)
e = create_engine("sqlite://", echo=True)
Base.metadata.create_all(e)
s = Session(e)
s.query(A.x).update(dict(x=5))
Traceback (most recent call last):
File "test.py", line 19, in <module>
s.query(A.x).update(dict(x=5))
File "/home/classic/dev/sqlalchemy/lib/sqlalchemy/orm/query.py", line 3286, in update
update_op.exec_()
File "/home/classic/dev/sqlalchemy/lib/sqlalchemy/orm/persistence.py", line 1162, in exec_
self._do_pre_synchronize()
File "/home/classic/dev/sqlalchemy/lib/sqlalchemy/orm/persistence.py", line 1216, in _do_pre_synchronize
target_cls = query._mapper_zero().class_
File "/home/classic/dev/sqlalchemy/lib/sqlalchemy/orm/query.py", line 294, in _mapper_zero
return self._entities[0].mapper
AttributeError: '_ColumnEntity' object has no attribute 'mapper'
either update() didn't call _mapper_zero() before or probably this is part of 81bd994c0adf43eb158a533b605c011fb552dd50 or related.
Comments (3)
-
reporter -
reporter -
reporter - changed status to resolved
Ensure .mapper is set on _ColumnEntity
_ColumnEntity didn't seem to have .mapper present, which due to the way _mapper_zero() worked didn't tend to come across it. With
3608
_mapper_zero() has been simplified so make sure this is now present. Also ensure that _select_from_entity is an entity and not a mapped class, though this does not seem to matter at the moment.Fixes:
#3836Change-Id: Id6dae8e700269b97de3b01562edee95ac1e01f80
→ <<cset 1f32d014da5d>>
- Log in to comment