custom op() has equal precedence to the comma operator

Issue #2537 resolved
Mike Bayer repo owner created an issue
from sqlalchemy import *
from sqlalchemy.sql import column

print func.xyz(column('5').op('bar')('bat'))

output:

xyz(("5" bar :5_1))

a patch which adjusts operator precedence rules to put "comma" below "smallest" is attached for evaluation, not sure if this is the best approach.

it's also possible to allow op() to accept a precedence argument.

Comments (4)

  1. Mike Bayer reporter

    workaround:

    from sqlalchemy.sql import column, func, literal_column
    
    # work around #2537 until SQLAlchemy 0.8
    from sqlalchemy.sql import operators
    operators._PRECEDENCE['SEPARATOR']('SEPARATOR') = 0
    
    expr = func.group_concat(column('urlname').op('SEPARATOR')(literal_column('/')))
    
    print expr
    
  2. Mike Bayer reporter

    second patch refines custom operators into a new object type, as well as modifies the dispatch system in CompareMixin to handle it. simplifies the compiler a slight bit and adds room in for more operator expansion.

  3. Log in to comment