group_concat, op and separator

1,974 views
Skip to first unread message

Sergey Kucheryavski

unread,
Jul 22, 2012, 8:30:53 AM7/22/12
to sqlal...@googlegroups.com
I try to use group_concat with SEPARATOR option as it was proposed in other topic but got a strange issue with using group_concat and op:

this expression:
print node.urlname.op('SEPARATOR')('/')
gives
node.urlname SEPARATOR :urlname_1

But this expression
print func.group_concat(node.urlname.op('SEPARATOR')('/'))
gives
group_concat((node.urlname SEPARATOR :urlname_1))

and these extra brackets in real query cause SQL error. Is there anything I am doing wrong?

Thanks a lot in advance!

Michael Bayer

unread,
Jul 22, 2012, 10:23:53 AM7/22/12
to sqlal...@googlegroups.com
that is a bug and here is a workaround:

from sqlalchemy.sql import column, func, literal_column

# work around [ticket:2537] until SQLAlchemy 0.8
from sqlalchemy.sql import operators
operators._PRECEDENCE['SEPARATOR'] = 0

expr = func.group_concat(column('urlname').op('SEPARATOR')(literal_column('/')))

print expr



--
You received this message because you are subscribed to the Google Groups "sqlalchemy" group.
To view this discussion on the web visit https://groups.google.com/d/msg/sqlalchemy/-/tkZZJh9bBYQJ.
To post to this group, send email to sqlal...@googlegroups.com.
To unsubscribe from this group, send email to sqlalchemy+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.

Sergey Kucheryavski

unread,
Jul 27, 2012, 7:25:25 AM7/27/12
to sqlal...@googlegroups.com
Thanks!
To unsubscribe from this group, send email to sqlalchemy+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages