[sqlalchemy] Re: order_by with explicit column name messes up subqueryload

2012-01-08 Thread Yuen Ho Wong
BTW, aliased() and alias() don't work on a label() either. I tried passing the label object straight into the order_by() as well to no avail. I'm all out of ideas. On Jan 9, 3:47 am, Yuen Ho Wong wyue...@gmail.com wrote: Hi, I have a rather complicated problem and I was wondering if you guys

[sqlalchemy] Re: order_by with explicit column name messes up subqueryload

2012-01-08 Thread Yuen Ho Wong
Except that LIMIT and OFFSET are present in my query, gnarly isn't it ? :P d = label(distance, some_complicated_geoalchemy_function_call(columns...)) q = session.query(Product, Merchant.location, d)\ .join(Merchant, Product.merchant_id == Merchant.id)\

[sqlalchemy] Re: order_by with explicit column name messes up subqueryload

2012-01-08 Thread Yuen Ho Wong
Here are the models: class Merchant(Base): __tablename__ = merchant id = Column(Integer, autoincrement=True, primary_key=True) location = GeometryColumn(Point, nullable=False) class SearchOption(Base): __tablename__ = searchoption id = Column(Integer, autoincrement=True,

Re: [sqlalchemy] Re: order_by with explicit column name messes up subqueryload

2012-01-08 Thread Michael Bayer
On Jan 8, 2012, at 3:16 PM, Yuen Ho Wong wrote: Except that LIMIT and OFFSET are present in my query, gnarly isn't it ? :P d = label(distance, some_complicated_geoalchemy_function_call(columns...)) q = session.query(Product, Merchant.location, d)\ .join(Merchant,

[sqlalchemy] Re: order_by with property of related table

2011-07-27 Thread Gunnlaugur Briem
Hi, you need to join explicitly on A.b: SESSION.query(A).join(A.b).order_by(B.name) Full example: http://pastebin.com/uMqEa6Cr Regards, - Gulli -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To view this discussion on the web visit

[sqlalchemy] Re: order_by(datetime)

2011-01-10 Thread F.A.Pinkse
Hi Michael, Thanks for your quick reply. I understand. I am using SQLite as the engine. I have not found the functions needed in the doc. I will leave this sort option open and stick with SQlite for a while. Frans Op 1/10/2011 4:03 PM, Michael Bayer schreef: you'd need to use SQL

[sqlalchemy] Re: order_by on a relationship() ?

2010-06-23 Thread Julien Cigar
forget it, I missed this in the docs : Note that when using joined eager loaders with relationships, the tables used by the eager load’s join are anonymously aliased. You can only order by these columns if you specify it at the relationship() level. To control ordering at the query level

[sqlalchemy] Re: order_by() and count()

2010-02-08 Thread gsandorx
I got it: from sqlalchemy.sql import func stmt = session.query(Prod.store_id, func.count('*').label('prod_count')).group_by(Prod.store_id).subquery() obj_q = session.query(Store, stmt.c.prod_count).outerjoin( (stmt, Store.id==stmt.c.store_id)).order_by(stmt.c.prod_count.desc())

[sqlalchemy] Re: order_by and group_by won't work as I want.

2008-12-19 Thread az
On Friday 19 December 2008 19:53:03 有末 清華 wrote: Hi. Well, I want to output the HTML code from database. And the HTML code should be order by 'cost' and group_by 'category' The database table is like below. --- ID CategoryName

[sqlalchemy] Re: Order_by

2008-06-30 Thread laureano arcanio
I found the solution using Joins. Thanks anyways. This is it: query = session.query(A).select_from(join(A, B)).order_by(B.some_attr) cheers --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post

[sqlalchemy] Re: order_by on related table

2007-12-05 Thread Michael Bayer
On Dec 5, 2007, at 1:56 PM, David Gardner wrote: I have three tables a(a query of a really), b, c a has a 1-many relationship with b c has a 1-many relationship with b What I would like to do is in my mapper for table c, is sort the order of rows from b by a.name. I don't know how to

[sqlalchemy] Re: order_by on related table

2007-12-05 Thread David Gardner
Michael thanks for the help, this is how I was able to get it working. Probably isn't the most efficient, but it works, I couldn't implement it the way you proposed because I still need to be able to do a_row = b_row.A - sql_b = select([b_table, sql_a.c.name], b_table.c.a_id =

[sqlalchemy] Re: ORDER_BY always in SELECT statements?

2007-10-01 Thread Michael Bayer
On Oct 1, 2007, at 8:20 AM, [EMAIL PROTECTED] wrote: Hi Michael, thanks for the help! The documentation mentions that this option over-rides the per-engine configuration but I couldn't find a create_engine option to set this. Any reference would be greatly appreciated! uhhh there is no

[sqlalchemy] Re: ORDER_BY always in SELECT statements?

2007-09-28 Thread Michael Bayer
On Sep 28, 2007, at 3:00 PM, [EMAIL PROTECTED] wrote: Hi, While trying to debug my script I set echo=True and checked the SQL statements that are generated. I noticed that all of the SELECTs issued to the DB have the ORDER_BY clause -- even though I didn't explicitly specify order_by()

[sqlalchemy] Re: order_by on related object attribute?

2007-04-20 Thread Gaetan de Menten
On 4/19/07, Michael Bayer [EMAIL PROTECTED] wrote: On Apr 19, 2007, at 9:39 AM, Gaetan de Menten wrote: By the way, lately I've been wishing SQLAlchemy would add a column (and possibly its table) automatically to the select clause if I do an order by a column which is not in the

[sqlalchemy] Re: order_by on related object attribute?

2007-04-18 Thread Michael Bayer
On Apr 18, 2007, at 12:21 AM, Chris Shenton wrote: I'm using SQLAlchemy with Pylons and query my 'system' table and order by their client_id field like: from er.models import System, Vendor, Client sys = self.session.query(System).select(System.c.lastseen self.this_week,

[sqlalchemy] Re: order_by

2007-04-16 Thread ml
e.g. order_by = [desc(table1.mycol)] Disrupt07 napsal(a): In my table I have a column with type Boolean. When using order_by on this column I am getting the results as follows: False False True True True ... True I want them the other way round (the True first, then the False).

[sqlalchemy] Re: order_by

2007-04-16 Thread Disrupt07
@ml Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more

[sqlalchemy] Re: order_by computed on wrong table with many-to-many

2007-04-02 Thread Alexandre CONRAD
Michael Bayer wrote: use 'sites':relation(Site, backref=backref('attachments', order_by=attachment_table.c.name)) for now. Ok, should I open a ticket for that ? On Mar 30, 5:50 am, Alexandre CONRAD [EMAIL PROTECTED] wrote: Hello, I have a problem with order_by on a many-to-many

[sqlalchemy] Re: order_by computed on wrong table with many-to-many

2007-03-30 Thread Michael Bayer
use 'sites':relation(Site, backref=backref('attachments', order_by=attachment_table.c.name)) for now. On Mar 30, 5:50 am, Alexandre CONRAD [EMAIL PROTECTED] wrote: Hello, I have a problem with order_by on a many-to-many relationship (using assign_mapper): --

[sqlalchemy] Re: order_by and alias

2006-12-30 Thread Manlio Perillo
Manlio Perillo ha scritto: [...] op = (a.c.x / a.c.y).label('z') query = select([op], order_by=[op], use_labels=True) The solution is quite simple (and very elegant): s = select([op], use_labels=True) s.order_by(s.c.z) Regards Manlio Perillo

[sqlalchemy] Re: order_by and alias

2006-12-30 Thread Michael Bayer
Manlio Perillo wrote: try: conn = db.connect() i = a.insert() conn.execute(i, x=6, y=5) op = (a.c.x / a.c.y).label('z') query = select([op], order_by=[op], use_labels=True) result = conn.execute(query).fetchall() for r in result: print r finally: