On 4/30/07, Michael Bayer <[EMAIL PROTECTED]> wrote:

> turns out scalar columns already work....since they are
> just...columns !  which ColumnProperty already handles.

That's what I tried to get at... that it was supposed to "just work"...

> any old SA
> version will allow the test script to work, if you use ColumnProperty
> explicitly along with two small fixes in sql.py.  in the trunk ive
> added those fixes, as well as reinstated the function "column_property
> ()" as a synonym for ColumnProperty and adapted your "eager" handling
> logic (also aliases the labels) so the columns work out in an eager
> relation, so mappings:

Thanks a lot for taking the trouble to fix those bugs.

There is (at least) one problem remaining though: subqueries do not
get correlated correctly. This is because the table in the main query
is aliased and the one in the subquery is not and that the
"correlator" in the Select class does not recognize an aliased table
as being the same as the original table.

I see two ways to fix this:

* The first and most easy one is to change the correlator to correlate
aliased tables with the original ones. Attached is patch which does
just that. But I highly suspect it's not correct to do that.

* The other option is obviously to aliasize the table in the
subquery... The problem with that is that the ClauseAdapter in
sql_util simply doesn't do it... And I didn't see a way to make it do
it since the "from" objects in a select are pretty much private. Any
idea?

-- 
Gaƫtan de Menten
http://openhex.org

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Index: sql.py
===================================================================
--- sql.py      (revision 2589)
+++ sql.py      (working copy)
@@ -2875,9 +2875,12 @@
         This basically means the given from object will not come out
         in this select statement's ``FROM`` clause when printed.
         """
+        if isinstance(from_obj, Alias):
+            original = from_obj.original
+        else:
+            original = from_obj
+        self.__correlated[original] = from_obj
 
-        self.__correlated[from_obj] = from_obj
-
     def append_from(self, fromclause):
         if type(fromclause) == str:
             fromclause = FromClause(fromclause)

Reply via email to