On Apr 1, 2014, at 6:34 AM, Alex <[email protected]> wrote: > Hmm, looks like I spoke too soon. Testing against a SQLite database the > hybrid attribute approach works fine but I'm having some trouble with SQL > Server. Basically, given the structure that Michael laid out, the following > query: > > model = TestModel( > flags=1 > ) > session.add(model) > session.commit() > result = session.query(TestModel).filter(TestModel.flag_one == > True).first() > > Resullts in this exception: > > ProgrammingError: (ProgrammingError) (102, "Incorrect syntax near '='.DB-Lib > error message 102, severity 15: > General SQL Server error: Check messages from the SQL Server > ") 'SELECT TOP 1 testmodel.id AS testmodel_id, testmodel.flags AS > testmodel_flags > FROM testmodel > WHERE ((testmodel.flags & %(flags_1)s) > %(param_1)s) = 1' {'flags_1': 1, > 'param_1': 0} > > So it looks like the equality comparison is coercing True to 1, I can't > figure out which hook I need to use to change this. I've tried to use > coerce_compared_value with no effect.
SQL server doesn't have a "boolean" type, you can only use one and zero. the issue there is more likely the bitwise comparison operators or the nesting of the parenthesis. get that query to work first at the SQL server console to figure out the syntax it wants. -- 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.
