Oleg Broytmann <phd <at> phd.pp.ru> writes:

>    That would be hard to implement, I am afraid. Select() is (must be) much
> more generic, supporting groupBy and many other features of SQL SELECT...

Correct that Select by itself must be more generic, I wouldn't be opening up
direct select() kw access to groupBy on SelectResults. But it's that flexibility
that I'm looking to abuse and inject into SelectResults. :) Don't let the
following example color this discussion too much, as I think the general idea of
providing a common interface is useful even without going this particular route:

class PhoneWithTotalMinutes(SQLObject):
    'for the moment imagine this class is never directly queried/instantiated.'
    number = StringCol()
    minutes = IntCol()

x = Select([Phone.q.id, Phone.q.number, AS(func.SUM(PhoneCall.q.minutes),
'minutes')], where=Phone.q.id==PhoneCall.q.phoneID, groupBy=Phone.q.id)

PhoneWithTotalMinutes.select(query=x)

Using the fact that Iteraction.next/_SO_selectInit will accept any result tuple
that matches the columnList. (I'm ignoring the fact that this particular example
could be statically defined as a view on the db side, or even possibly
statically stored as sqlmeta.table, as currently I'm interested in representing
it on the python side in the pending state of being a malleable SelectResults.)
 
> > I'm thinking that sqlbuilder.Table (or at least AliasTable) should also
> > eventually get in on this fun, probably growing a .select method that
> > returns a Select that can then be filter'ed etc.
> 
>    Why? sqlbuilder.Table is (was) an internal object used in q-magic, why
> bring it to the front?

Fair enough for the moment, this motivation is because I would expect
Alias(Select()) to have such method(s) (returning a Select), and then to behave
the same later on if there happens to be an Alias(Table()). But I'm mostly faced
with Alias(Select()) right now, so we can play this out a further to see if it's
a good idea first. Regardless it's only a matter of converting a Table to a
Select (at least for SQLObjectTables this is straightforward, less clear on
plain Table with no column spec).

- Luke


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
sqlobject-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to