No, no PickleTypes. And my manual testing shouldn't have any other objects in session.dirty -- but I'll double-check that. The two classes with a custom comparator (which uses "==" in any case) is never seen by this module -- and they're never updated by any code in this server.
There's a session.commit() just prior to the code I posted, so the session should be clean, shouldn't it? I'll poke at session.dirty and see if anything is lurking there. On Wednesday, April 29, 2015 at 6:39:12 AM UTC-7, Michael Bayer wrote: > > > > On 4/29/15 9:25 AM, Bill Schindler wrote: > > This error is being thrown on code that worked with 0.9.8. It seems to be > checking a comparison on something, but I can't figure out which "this > clause" the exception is referring to. Here's the stripped-down code > leading up to the commit: > > ancient = utcnow() - timedelta(hours=8) > ancient_conn = ( > (LiveSession.isconnected) & > (LiveSession.connected < ancient)) > for conn in session.query(LiveSession).filter(ancient_conn): > conn.isconnected = False > conn.disconnected = func.now() > session.commit() > > I've tried it without the loop and it fails about 75% of the time with > the same traceback. I'm also getting this exception on another ORM object > that has a string column and four timestamp columns (and isn't updated in a > loop). Test updating that object also gives me the same exception about 75% > of the time on flush. > > Neither ORM object has any relationships or anything other than straight > column definitions. > > File > "/opt/certwise-lcs/eggs/lcs.web.events-1.0.0-py2.7.egg/lcs/web/events/utility.py", > > line 296, in _dead > session.commit() > File > "/opt/certwise-lcs/eggs/SQLAlchemy-1.0.2-py2.7-linux-x86_64.egg/sqlalchemy/orm/session.py", > > line 790, in commit > self.transaction.commit() > File > "/opt/certwise-lcs/eggs/SQLAlchemy-1.0.2-py2.7-linux-x86_64.egg/sqlalchemy/orm/session.py", > > line 392, in commit > self._prepare_impl() > File > "/opt/certwise-lcs/eggs/SQLAlchemy-1.0.2-py2.7-linux-x86_64.egg/sqlalchemy/orm/session.py", > > line 372, in _prepare_impl > self.session.flush() > File > "/opt/certwise-lcs/eggs/SQLAlchemy-1.0.2-py2.7-linux-x86_64.egg/sqlalchemy/orm/session.py", > > line 2004, in flush > self._flush(objects) > File > "/opt/certwise-lcs/eggs/SQLAlchemy-1.0.2-py2.7-linux-x86_64.egg/sqlalchemy/orm/session.py", > > line 2122, in _flush > transaction.rollback(_capture_exception=True) > File > "/opt/certwise-lcs/eggs/SQLAlchemy-1.0.2-py2.7-linux-x86_64.egg/sqlalchemy/util/langhelpers.py", > > line 60, in __exit__ > compat.reraise(exc_type, exc_value, exc_tb) > File > "/opt/certwise-lcs/eggs/SQLAlchemy-1.0.2-py2.7-linux-x86_64.egg/sqlalchemy/orm/session.py", > > line 2086, in _flush > flush_context.execute() > File > "/opt/certwise-lcs/eggs/SQLAlchemy-1.0.2-py2.7-linux-x86_64.egg/sqlalchemy/orm/unitofwork.py", > > line 373, in execute > rec.execute(self) > File > "/opt/certwise-lcs/eggs/SQLAlchemy-1.0.2-py2.7-linux-x86_64.egg/sqlalchemy/orm/unitofwork.py", > > line 532, in execute > uow > File > "/opt/certwise-lcs/eggs/SQLAlchemy-1.0.2-py2.7-linux-x86_64.egg/sqlalchemy/orm/persistence.py", > > line 170, in save_obj > mapper, table, update) > File > "/opt/certwise-lcs/eggs/SQLAlchemy-1.0.2-py2.7-linux-x86_64.egg/sqlalchemy/orm/persistence.py", > > line 613, in _emit_update_statements > lambda rec: ( > File > "/opt/certwise-lcs/eggs/SQLAlchemy-1.0.2-py2.7-linux-x86_64.egg/sqlalchemy/orm/persistence.py", > > line 456, in _collect_update_commands > value, state.committed_state[propkey]): > File > "/opt/certwise-lcs/eggs/SQLAlchemy-1.0.2-py2.7-linux-x86_64.egg/sqlalchemy/sql/elements.py", > > line 2726, in __bool__ > raise TypeError("Boolean value of this clause is not defined") > exceptions.TypeError: Boolean value of this clause is not defined > > > this error is not related to the code illustrated above; it has to do with > an object that is present in session.dirty which has some kind of SQL > expression clause inside of its state, but also seems related to using an > odd kind of comparison function within a custom type, likely a PickleType > that is using a custom "comparator" function. > > I can create this stack trace exactly. But I have to do something really > weird to make it happen. It doesn't provide the failure in 0.9.9 so is a > regression. But super curious if you have something in your mapping that > looks like this: > > from sqlalchemy import * > from sqlalchemy.orm import * > from sqlalchemy.ext.declarative import declarative_base > > Base = declarative_base() > > def comparator(a, b): > return a > b > > class A(Base): > __tablename__ = 'a' > id = Column(Integer, primary_key=True) > data = Column(PickleType(comparator=comparator)) > > > e = create_engine("sqlite://", echo=True) > Base.metadata.create_all(e) > > s = Session(e) > s.add(A(data='some data')) > s.commit() > > a1 = s.query(A).first() > a1.data = func.foo("im a SQL expression") > s.commit() > > > are you using PickleType, with a custom comparator that doesn't come down > to using "==", and are using a SQL expression as the value to be persisted? > > > > > > > > > > > > -- > Bill > -- > 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 <javascript:>. > To post to this group, send email to sqlal...@googlegroups.com > <javascript:>. > Visit this group at http://groups.google.com/group/sqlalchemy. > For more options, visit https://groups.google.com/d/optout. > > > -- 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+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.