Improper column quoting with ORDER BY

Issue #3020 resolved
Jon Nelson created an issue

Below, please find a chunk of code. You'll note that - at least on 0.9.4 - the generated statement doesn't quote the column in the ORDER BY.

import sqlalchemy as sa
import sqlalchemy.dialects.postgresql as sa_pg
import sqlalchemy.dialects.mysql as sa_mysql

m = sa.MetaData()
t = sa.Table(
  'foo', m,
  sa.Column('a', sa.String()),
)

c = t.c.a.label('t.c.a')
q = sa.select([c])
q = q.order_by( c )

print q.compile(dialect=sa_pg.dialect())
print q.compile(dialect=sa_mysql.dialect())

Comments (3)

  1. Mike Bayer repo owner

    that "t.c.a" was throwing me off in the description, but this is a bona-fide regression of #1068, as this is a new feature in 0.9, here's a more succinct test:

    from sqlalchemy.sql import select, column
    
    cl = column('x').label('YX')
    print select([cl]).order_by(cl)
    
  2. Mike Bayer repo owner
    • Fixed regression introduced in 0.9 where new "ORDER BY <labelname>" feature from 🎫1068 would not apply quoting rules to the label name as rendered in the ORDER BY. fix #3020, re: #1068

    → <<cset fcda519452cf>>

  3. Log in to comment