Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #1319 (closed defect: fixed)

Opened 11 years ago

Last modified 10 years ago

[PATCH] @paginate barfs if you try to sort on a column whose data is generated from SQL

Reported by: alastair Owned by: faide
Priority: normal Milestone: 1.0.3
Component: SQLAlchemy Version: 1.0
Severity: normal Keywords:
Cc:

Description

If you map against a select, you can generate columns (attributes) using SQL functions, for instance:

s = select([foo.c.name, func.count(foo.c.name).label('count')],
           group_by=[foo.c.name]).alias('statistics')

class FooNameStatistics(object):
    pass

m = mapper(FooNameStatistics, s)

If you then try to use this with @paginate, you'll find that trying to sort by the generated column doesn't work, because the code currently checks for sqlalchemy.schema.Column rather than sqlalchemy.sql.ColumnElement.

I've attached a patch that fixes this.

Attachments

sqla2.diff Download (511 bytes) - added by alastair 11 years ago.
Patch to make paginate check for sql.ColumnElement? rather than schema.Column

Change History

Changed 11 years ago by alastair

Patch to make paginate check for sql.ColumnElement? rather than schema.Column

comment:1 Changed 11 years ago by alastair

(Probably worth referencing #1318 and #1115 here.)

comment:2 Changed 11 years ago by alastair

  • Summary changed from @paginate barfs if you try to sort on a column whose data is generated from SQL to [PATCH] @paginate barfs if you try to sort on a column whose data is generated from SQL

Make it clear there's a patch attached.

comment:3 Changed 11 years ago by alberto

Could someone please test this?

Alberto

comment:4 Changed 10 years ago by alberto

  • Milestone changed from 1.0.2 to 1.0.3

comment:5 Changed 10 years ago by faide

  • Owner changed from anonymous to faide

comment:6 Changed 10 years ago by faide

Applied in 1.0 and trunk (r3066 & r3067) thanks Alastair!

comment:7 Changed 10 years ago by faide

  • Status changed from new to closed
  • Resolution set to fixed
Note: See TracTickets for help on using tickets.