RowProxy does not correctly name aggregate columns under Sqlite

Issue #459 resolved
Former user created an issue

The keys and attributes for columns that are the result of an aggregate function are not mapped properly under Sqlite.

In postgres, when calling keys() on a row of the result set, a column aggregated with the MAX() function returns a column key of 'max'. Under Sqlite keys() will return 'somerow)' as the column name. Attribute access to the column also fails.

I have attached a test program that demonstrates the error. It appears when using SQLAchemy 0.3.4, with Sqlite 3.3.3 and psycopg 2.0.5.1.

Comments (4)

  1. Mike Bayer repo owner

    this is a SQLite issue. the workaround is to use a label for your column:

    stmt = select([func.max(testable.c.val).label('myfunc')](func.max(testable.c.val).label('myfunc')))
    
  2. Log in to comment