[Sqlalchemy-tickets] Issue #3469: comparison in persistence.py can trip up on clauseelement sitauti
Brought to you by:
zzzeek
|
From: Mike B. <iss...@bi...> - 2015-07-01 17:01:12
|
New issue 3469: comparison in persistence.py can trip up on clauseelement sitautions https://bitbucket.org/zzzeek/sqlalchemy/issue/3469/comparison-in-persistencepy-can-trip-up-on Mike Bayer: We're seeing stack traces like this: ``` #! File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/session.py", line 2122, in _flush transaction.rollback(_capture_exception=True) File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/util/langhelpers.py", line 60, in __exit__ compat.reraise(exc_type, exc_value, exc_tb) File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/session.py", line 2086, in _flush flush_context.execute() File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/unitofwork.py", line 373, in execute rec.execute(self) File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/unitofwork.py", line 532, in execute uow File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/persistence.py", line 170, in save_obj mapper, table, update) File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/persistence.py", line 630, in _emit_update_statements lambda rec: ( File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/persistence.py", line 459, in _collect_update_commands value, state.committed_state[propkey]): File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/sql/elements.py", line 2726, in __bool__ raise TypeError("Boolean value of this clause is not defined") TypeError: Boolean value of this clause is not defined ``` examples include numpy objects as well as geoalchemy2 objects: ``` #!python import geoalchemy2 from sqlalchemy import * from sqlalchemy.orm import * from sqlalchemy.ext.declarative import declarative_base Base = declarative_base() class A(Base): __tablename__ = 'tests' id = Column(Integer, primary_key=True) geom = Column(geoalchemy2.Geometry('POLYGON')) e = create_engine("postgresql://scott:tiger@localhost/test", echo=True) Base.metadata.create_all(e) s = Session(e) s.add(A(id=1, geom='POLYGON((0 0,1 0,1 1,0 1,0 0))')) s.commit() a1 = s.query(A).first() a1.geom = None s.commit() ``` in 0.9 we use attributes.from_scalar_attribute() which does the is_equals() and then compares it to "is True", so that's why we're suddenly failing. |