Re: [sqlalchemy] MySQL group_concat() with both ORDER BY and SEPARATOR

2020-12-15 Thread Mike Bayer
as this involves a MySQL-specific syntax, the easiest way to just make this happen without any hassle is to use literal_column(), such as: q1 = s.query( func.group_concat( literal_column( "DISTINCT lower(`role`.`name`) ORDER BY lower(`role`.`name`) SEPARATOR '|'"

[sqlalchemy] MySQL group_concat() with both ORDER BY and SEPARATOR

2020-12-15 Thread jjbrei...@gmail.com
I want to execute the following MySQL query: SELECT group_concat(DISTINCT lower(`role`.`name`) ORDER BY lower(`role`.`name`) SEPARATOR '|') FROM ... GROUP BY ... Using the latest stable release of SQLAlchemy (1.3.20), I've written the following code: class Role(Base): __tablename__ =