- changed status to resolved
comparison in persistence.py can trip up on clauseelement sitautions
Issue #3469
resolved
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:
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.
Comments (1)
-
reporter - Log in to comment
__eq__()
to return a non-boolean-capable object, such as some geoalchemy types as well as numpy types, were being tested forbool()
during a unit of work update operation, where in 0.9 the return value of__eq__()
was tested against "is True" to guard against this. fixes#3469→ <<cset ee34f7276b8c>>