Skip to content

Issue with ordering #36

@steveoni

Description

@steveoni

While trying to use /aggregate and /facts this specific line for ordering

ordering, q, bindings = Ordering(self).apply(q, bindings, order)

is generating variables not in any of the tables

sqlalchemy.exc.ProgrammingError: (psycopg2.errors.UndefinedTable) missing FROM-clause entry for table "anon_2"
LINE 2: FROM "R_kgDOGLhFbw4edfc924721abb77" ORDER BY anon_2.anon_1 A...

and here is the generated sql query

[SQL: SELECT NULL AS anon_1, count("R_kgDOGLhFbw4edfc924721abb77".activity_id) AS _count, sum("R_kgDOGLhFbw4edfc924721abb77"."MONTO_ADEFAS") AS "MONTO_ADEFAS.sum", sum("R_kgDOGLhFbw4edfc924721abb77"."MONTO_APROBADO") AS "MONTO_APROBADO.sum", sum("R_kgDOGLhFbw4edfc924721abb77"."MONTO_DEVENGADO") AS "MONTO_DEVENGADO.sum", sum("R_kgDOGLhFbw4edfc924721abb77"."MONTO_EJERCICIO") AS "MONTO_EJERCICIO.sum", sum("R_kgDOGLhFbw4edfc924721abb77"."MONTO_EJERCIDO") AS "MONTO_EJERCIDO.sum", sum("R_kgDOGLhFbw4edfc924721abb77"."MONTO_MODIFICADO") AS "MONTO_MODIFICADO.sum", sum("R_kgDOGLhFbw4edfc924721abb77"."MONTO_PAGADO") AS "MONTO_PAGADO.sum" 
FROM "R_kgDOGLhFbw4edfc924721abb77" ORDER BY anon_2.anon_1 ASC NULLS LAST, anon_2._count ASC NULLS LAST, anon_2."MONTO_ADEFAS.sum" ASC NULLS LAST, anon_2."MONTO_APROBADO.sum" ASC NULLS LAST, anon_2."MONTO_DEVENGADO.sum" ASC NULLS LAST, anon_2."MONTO_EJERCICIO.sum" ASC NULLS LAST, anon_2."MONTO_EJERCIDO.sum" ASC NULLS LAST, anon_2."MONTO_MODIFICADO.sum" ASC NULLS LAST, anon_2."MONTO_PAGADO.sum" ASC NULLS LAST 
 LIMIT %(param_1)s]
[parameters: {'param_1': 100}]

but commenting out the ordering line, the api works fine. is there something i'm doing wrong

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions