Robert Buchholz <[email protected]> wrote:
> Hello, > > I am trying to write the following query in MySQL (in essence): > SELECT TRIM(TRAILING "-2" FROM c.slug) > FROM categories c; > > In reality, the column this is run on is an anonymous aliased table in a > JOIN expression*. Is it possible to generate the TRIM(TRAILING X FROM Y) > with an SQLa function? this is a custom SQL format so you’d want to use @compiles. you can probably subclass ColumnElement. FunctionElement might work also, scan through http://docs.sqlalchemy.org/en/rel_0_9/core/compiler.html# for details. > > > Cheers, > > Robert > > > > * The whole thing looks like this: > SELECT * > FROM categories c > JOIN categories c2 > ON c.slug = > TRIM(TRAILING "-2" FROM c2.slug) > WHERE c2.slug LIKE "%-2"; > > > -- > You received this message because you are subscribed to the Google Groups > "sqlalchemy" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/sqlalchemy. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.
