Commits

Olemis Lang committed a096517

TracGViz: Flat schema before applying GViz QL expression transformations

Comments (0)

Files changed (1)

trac-dev/gviz/tracgviz/gvizql.py

 from re import compile
 from weakref import proxy
 
+from tracgviz.api import DataTable
 from tracgviz.util.parsing import OperatorPrecedenceParser,  \
     InvalidParserConfiguration
 
     return (sch, data)
   else:
     tq = GVizQLParser().parse(tq)
+    sch = provider.get_data_schema(*sch_args)
     data = provider.get_data(req, tq, **params)
-    sch = provider.get_data_schema(*sch_args)
-    return tq.transform(sch, data)
+    table = DataTable(sch)
+    # FIXME : Optimize memory
+    table.LoadData(data)
+    sch = [(col['id'], col['type']) + \
+        ( (col['label'],) if col.get('label') else () ) \
+        for col in table.columns]
+    data_seq = ( tuple(row.get(col['id']) for col in table.columns) \
+        for row in table._PreparedData() )
+        
+    return tq.transform(sch, data_seq)
 
 class Sequence(list):
   pass