Oleg Broytmann wrote:
> On Fri, Aug 03, 2007 at 04:24:14PM +0200, Johan Carlsson wrote:
>   
>> It's for taking a select object created with sqlbuilder.Select and 
>> return a SelectResults derived class of it,
>> that can be iterated over ir or over slices, or call methods like 
>> count() and etc.
>>     
>
>    Luke Oppermann did a unification in the trunk and merged SelectResults,
> Select() and dbconnection.queryForSelect(). Now Select() is the
> lowest-level API that implements all features - joins, slices, distinct,
> - and SelectResults uses Select().
>    Does it solve you problems (in a different way)?
>   
Well, partly (because it's those changes I use to override to get my 
classes working).

But if I understand the code correctly I still have to submit a 
SQLObject derived class as the sourceClass to SelectResults?
And I've revised the code and there is no way to set a custom "items" 
attribute for the Select.

I've solved the issue with a custom result class (what I call brain) by 
making a fake SQLObject class with an attribute columnList to defines 
all the columns of the query.
It sets it manually maps the result tuple from the query to the 
attributes in it's "_init" method.

I think it would be nice to be able to pass an external Select-object to 
SelectResults when it's created.
That is basically what my class does.

(a bit of topic)
I have also not found a way to set names on the columns returned by 
Select(),
for instance I have a COUNT() in one of my Select and the only way I've
been able to access it is by index into the returned tuple.
(My fake brain class uses the order of the defined columns to make the 
tuple index to a name.)

(another of topic issue, that I should maybe post seperate?)
There are some comments in the SelectResults code (e.g. in the count metod)

            # Column must be specified, so we are using unique ID column.
            # COUNT(DISTINCT column) is supported by MySQL and PostgreSQL,
            # but not by SQLite. Perhaps more portable would be subquery:
            #  SELECT COUNT(*) FROM (SELECT DISTINCT id FROM table)

Well making it a subquery makes huge sense for me, because I use groupBy to
group my result calculating some statistics and that makes count return 
a bogus
value. So at least when groupBy is used this would be preferred (imho).
I'm not a SQL wizard so I don't know what's the most 
proper/efficient/compatible
way to do it.

Maybe I should have a chat with Luke Oppermann :-D

Regards,
Johan Carlsson


 


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to