|
From: David M. C. <da...@da...> - 2004-07-30 04:11:18
|
On Fri, May 28, 2004 at 11:49:54AM -0400, Ian Sparks wrote:
> Before I start digging into the source code does the following ability
> already exist in SQLObject and, if not, does anyone else want it.
You can do
Klass._connection.queryAll(sql)
For example, I needed to quickly get a lookup dictionary of row IDs of a
table that were in a joined table, so that I could determine which items in
a tree widget would get expanders (without having to load all the joining
objects)
result = Klass.select(Join_klass.q.klassID==Klass.q.id)
lookup = dict([(o.id,None) for o in result])
works OK, but
dict(Klass._connection.queryAll("select klass_id, NULL from join_klass"))
is 10 times faster even with cached objects. I think I saw that fetching
only IDs instead of objects was on the TODO list.
Dave Cook
> AFAIK SQLObject can't do complex joins. For instance, I might want to do a query like :
>
> SELECT TimeOfRequests.* FROM TimeOffRequests INNER JOIN Users ON TimeOffRequests.cUserID = Users.cID WHERE Users.Dept = 12
>
> The result will be a set of "A" objects so I'd like SO to treat them as such. So if SQLObject doesn't already support it what I'd like to be able to do is :
>
> timeOffReqs = TimeOffRequests.get(passThrough="SELECT TOR.* FROM TimeOffRequests TOR INNER JOIN Users U ON TOR.cUserID = U.cID WHERE U.Dept = 12")
>
> Obviously, I've just broken the portability of my code so if there were a more SO-ish way of doing it I'd gladly take the education.
>
> However, in some DB's like Firebird you can get SQL results from a StoredProc or a view or something and this pass-through capability could prove useful.
>
> Thoughts?
>
>
>
>
>
>
>
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by: Oracle 10g
> Get certified on the hottest thing ever to hit the market... Oracle 10g.
> Take an Oracle 10g class now, and we'll give you the exam FREE.
> http://ads.osdn.com/?ad_id149&alloc_id66&op=click
> _______________________________________________
> sqlobject-discuss mailing list
> sql...@li...
> https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss
|