Michael Bayer wrote:
> On Jun 25, 2008, at 10:48 AM, Huy Do wrote:
>
>   
>> Hi,
>>
>> I read in the 0.5 release notes that the c attribute was no longer
>> necessary when doing queries using the mapped class, but I did not see
>> it mentioned that the c attribute was removed all together.
>>
>> It's just that I've been using the c attribute in my Mapped classes to
>> access the database/table metadata and now all my code will need to be
>> changed to use the table.c attribute instead.
>>
>> Was there a reason for removing the c attribute from mapped classes
>> altogether ?
>>
>>     
>
> in 0.5, the attributes on classes vs. the columns on Tables are very  
> different beasts now.   Its not at all the same thing if you say:
>
> sess.query(MyClass.id, MyClass.name)
>
> vs.
>
> sess.query(mytable.c.id, mytable.c.name)
>
>
> since in the former case, we know that we are dealing with the MyClass  
> mapper; in the latter case, we're not.  The behavior of things like  
> join(), polymorphic loading, other options, etc. are completely  
> different - in the case of joined table inheritance it's dramatically  
> different, where "Subclass.id" and "subtable.c.id" are literally  
> different columns.   So we really can't have a casual ".c." attribute  
> hanging around on classes with the new behavior;  the user needs to be  
> very explicit when choosing between MyClass.attr vs. table.c.attr.
>
> That said, you can retroactively add your ".c." attribute using a  
> MapperExtension that implements "instrument_class()", and assigns the  
> "c" attribute from the table to the class.
>   
Michael,

Thanks for the suggestion. Is there any metadata on the MyClass.id field 
at all ? like which column it's mapped too ?

Lucky for me, I don't use any of the advanced SA features like 
inheritance and polymorphic stuff, so usually my MyClass.id is the same 
as my mytable.c.id (in the old SA).

Thanks again,

Huy

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to