On Fri, Dec 24, 2010 at 11:56:01AM -0500, Ben Timby wrote:
> Oleg, once again, thank you.
>
> I was looking for the MAX function and was unable to find it. Const is
> interesting as well, it takes the provided attr and transforms it to
> verbatim in the resulting SQL, neat.
``const`` and ``fun
On Fri, Dec 24, 2010 at 10:44 AM, Oleg Broytman wrote:
> 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)
>
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, st
The python code was wrong in my last email, it was what I THOUGHT it
should be, the python that produces the bad SQL is:
--
query = Sync.select(
AND(
Sync.q.syncpoint==self,
Sync.q.serial==sqlbuilder.Select('max(serial)',
Sync.q.syncpoint==self, staticTables=('sync',))
)
)
On Thu, Dec 23, 2010 at 5:58 PM, Oleg Broytman wrote:
> .select().max() produces a simple query SELECT MAX(). If you need a
> query with a subquery you need to add the subquery explicitly using
> sqlbuilder.Select():
>
> serial = Path.select(
> Path.q.serial==Select('max(serial)', staticTabl
On Wed, Dec 22, 2010 at 10:18:49PM -0500, Ben Timby wrote:
> What is the most expedient way to do the following?
>
> serial = Path.selectBy().max('serial')
> return Path.getOne(serial=serial)
>
> I would like some SQL like this:
>
> select * from path where serial = (select max(serial) from path