[Sqlalchemy-tickets] Issue #4183: Using func.sum(BinaryExp), returns boolean instead of a sum (wasn
Brought to you by:
zzzeek
From: Bastien G. <iss...@bi...> - 2018-02-07 15:59:45
|
New issue 4183: Using func.sum(BinaryExp), returns boolean instead of a sum (wasn't the case in 1.1.12) https://bitbucket.org/zzzeek/sqlalchemy/issues/4183/using-funcsum-binaryexp-returns-boolean Bastien Gérard: Hi, First of all, we are using MySQL 5.6 After switching from sqlalchemy 1.1.12 to 1.2.2, we observed that one of our test failed. In fact the following scenario should return a RowProxy with the values being the sum but the values are boolean instead. ``` #!python from sqlalchemy import select from sqlalchemy.sql.functions import func engine, tbl, col = ... sel = select([func.sum(col.is_(None))]) print sel # SELECT sum(smart_result.signal_predicted IS NULL) AS sum_1 FROM smart_result row = engine.execute(sel).fetchone() print dict(row) # {u'sum_1': True} # And if I execute it manually: r = engine.execute('SELECT sum(smart_result.signal_predicted IS NULL) AS sum_1 FROM smart_result') print r.fetchall() # [(Decimal('120'),)] ``` I don't know if it could be related but by printing row._key_map, I see references to "<function sqlalchemy.cprocessors.int_to_boolean>". |