On Jan 8, 2011, at 3:23 PM, Petra Clementson wrote:

> I want to do a self join on combined but it wont let me. Essensially,
> I want to join two different tables, and create aliases so I can
> compare one column and make sure that each item in the column is
> uniqe. If there are duplicates, I want my piece of code to show the
> duplicates. Combining join with alias seems like the best way to do
> this because when using other methods, if I change the duplicates to a
> unique name, the name that used to be a duplicate still prints.  Note
> that the Header table has a foreign key reference to DiskFile and the
> sql version used was 0.6.5. This is the portion of code where I am
> getting an error:
> 
> 
> combined = join(DiskFile, Header)
> combined_alias = aliased(combined)
> 
> 
> ERROR:
> Traceback (most recent call last):
>  File "duplicatedl.py", line 32, in <module>
>    combined_1 = aliased(combined)
> 
>  File "/opt/sqlalchemy/lib/python2.5/site-packages/sqlalchemy/orm/
> util.py", line
> 304, in __init__
>    self.__target = self.__mapper.class_
> AttributeError: 'SQLCompiler' object has no attribute 'class_'

This could perhaps be improved in the interface; "aliased()" applies to mapped 
classes and mappers.  join() is a Selectable expression.   To alias a 
selectable, use its alias() method to generate an alias object:

join(A, B).alias()


I'll think about having orm.aliased() detect a selectable and return 
selectable.alias() in 0.7.


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

Reply via email to