- changed status to invalid
extract(year,datefield) does not work for firebird
using sqlalchemy-0.6.6, firebird-2.5.0
my code: mapper(FilterYr,doc, include_properties='tdate','id','net','vat', properties={ 'yr' : column_property(sql.select(doc.c.tdate)) } )
where tdate is type DATE gives errors:
firebird/base.py", line 681, in do_execute cursor.execute(statement, parameters or []) ProgrammingError: (ProgrammingError) (-104, 'isc_dsql_prepare: \n Dynamic SQL Error\n SQL error code = -104\n Token unknown - line 1, column 33\n ?') 'SELECT FIRST 27 (SELECT extract(?, doc.tdate) AS extract_1 \nFROM doc) AS anon_1, doc.id AS doc_id, doc.net AS doc_net, doc.vat AS doc_vat, doc.tdate AS doc_tdate \nFROM doc' ('year',)
generated syntax should be 'extract(year from field)'
the sql statement below works:
select extract(year from tdate) yr, (extract(month from tdate) +2) / 3 qtr, e.curr, e.class, sum(e.amount) amount, explain.desc from doc inner join expitem e on e.doc_id = doc.id inner join explain on e.class = code where type in ('E') group by yr,qtr,e.curr,e.class,explain.desc
Comments (1)
-
repo owner - Log in to comment
the correct function for "extract" is "sqlalchemy.extract": http://www.sqlalchemy.org/docs/core/expression_api.html#sqlalchemy.sql.expression.extract