Ticket #1319 (closed defect: fixed)

Opened 1 year ago

Last modified 10 months ago

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

Reported by: alastair Assigned to: 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 (511 bytes) - added by alastair on 03/07/07 08:42:18.
Patch to make paginate check for sql.ColumnElement? rather than schema.Column

Change History

03/07/07 08:42:18 changed by alastair

  • attachment sqla2.diff added.

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

03/07/07 08:43:12 changed by alastair

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

03/07/07 08:50:49 changed 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.

04/05/07 16:50:57 changed by alberto

Could someone please test this?

Alberto

05/01/07 12:57:00 changed by alberto

  • milestone changed from 1.0.2 to 1.0.3.

06/02/07 17:21:40 changed by faide

  • owner changed from anonymous to faide.

06/03/07 09:10:01 changed by faide

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

06/03/07 09:10:09 changed by faide

  • status changed from new to closed.
  • resolution set to fixed.