On Fri, Dec 24, 2010 at 10:09:49AM -0500, Ben Timby wrote: > Thanks for your reply Oleg. I am sorry, but the above produces a bad query: > > -- > query = Sync.select( > AND( > Sync.q.syncpoint==self, > Sync.q.serial==sqlbuilder.Select(MAX('serial'), > Sync.q.syncpoint==self, staticTables=('sync',)) > ) > ) > -- > SELECT sync.id, sync.syncpoint_id, sync.serial, sync.stamp, > sync.status, sync.message FROM sync WHERE (((sync.syncpoint_id) = (1)) > AND ((sync.serial) = (SELECT 'max(serial)' FROM sync WHERE > ((sync.syncpoint_id) = (1))))); > -- > > As you can see, the 'max(serial)' ends up inside quotes within the > subselect. I can't find any MAX aggregate function to use in place of > the string...
Oops, columns in Select cannot be strings - to allow strings in queries. Use sqlbuilder.Select(sqlbuilder.func.MAX(sqlbuilder.const.serial) from sqlobject.sqlbuilder import Select, func, const Select(func.MAX(const.serial) looks better for my eyes. Oleg. -- Oleg Broytman http://phdru.name/ p...@phdru.name Programmers don't die, they just GOSUB without RETURN. ------------------------------------------------------------------------------ Learn how Oracle Real Application Clusters (RAC) One Node allows customers to consolidate database storage, standardize their database environment, and, should the need arise, upgrade to a full multi-node Oracle RAC database without downtime or disruption http://p.sf.net/sfu/oracle-sfdevnl _______________________________________________ sqlobject-discuss mailing list sqlobject-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss