~storm/storm/trunk

« back to all changes in this revision

Viewing changes to storm/expr.py

  • Committer: Thomas Hervé
  • Date: 2011-05-16 11:12:48 UTC
  • mfrom: (390.1.7 distinct-on)
  • Revision ID: thomas@canonical.com-20110516111248-4w33k0wlzfwe2ghd
Merge distinct-on [a=wgrant] [r=danilo,therve] [f=374777]

Add support for Postgres DISTINCT ON queries.

Show diffs side-by-side

added added

removed removed

Lines of Context:
656
656
@compile.when(Select)
657
657
def compile_select(compile, select, state):
658
658
    tokens = ["SELECT "]
 
659
    state.push("auto_tables", [])
 
660
    state.push("context", COLUMN)
659
661
    if select.distinct:
660
662
        tokens.append("DISTINCT ")
661
 
    state.push("auto_tables", [])
662
 
    state.push("context", COLUMN)
 
663
        if isinstance(select.distinct, (tuple, list)):
 
664
            tokens.append(
 
665
                "ON (%s) " % compile(select.distinct, state, raw=True))
663
666
    tokens.append(compile(select.columns, state))
664
667
    tables_pos = len(tokens)
665
668
    parameters_pos = len(state.parameters)