this issue is not specific to the recent changes;  this would happen  
even with the old behavior (since exclude_properties was meant to  
mean, "I dont want SQLA to know about this column at all" typically in  
a reflection scenario).  its fixed in r4966.


On Jul 22, 2008, at 7:27 AM, Malthe Borch wrote:

>
> Michael Bayer wrote:
>> well, i can support this in 0.5 trunk.  in rev 4965, If a descriptor
>> is present on a class, or if the name is excluded via the include/
>> exclude lists, the attribute will not be instrumented via the
>> inherited mapper or via the mapped Table.  So your example works with
>> just the @property alone.
>
> I've managed to demonstrate the issue in an isolated test (see below).
> The only change from the previous is that I've set a default value.
>
> This causes SQLAlchemy to *prefetch* the 'col' column, but this throws
> an exception since the column is not mapped.
>
> from sqlalchemy import *
> from sqlalchemy.orm import *
>
> e = create_engine('sqlite://')
> m = MetaData(e)
>
> t1= Table(
>      't1', m,
>      Column('id', Integer, primary_key=True),
>      Column('col', String(50), default=u""),
>      )
> t1.create()
>
> t2= Table(
>      't2', m,
>      Column('id', Integer, ForeignKey("t1.id"), primary_key=True),
>      Column('data', String(50)),
>      )
> t2.create()
>
> class T1(object):
>      pass
>
> class T2(T1):
>      @property
>      def col(self):
>          return u"Some read-only value."
>
> polymorphic = (
>      [T2], t1.join(t2))
>
> mapper(T1, t1)
> mapper(
>      T2, t2,
>      exclude_properties=('col',),
>      with_polymorphic=polymorphic,
>      inherits=T1,
>      inherit_condition=(t1.c.id==t2.c.id),
>      )
>
> sess = sessionmaker()()
> x = T2()
>
> assert type(T2.col) is property
>
> x.data = "some data"
> sess.save(x)
> sess.commit()
> sess.clear()
>
> assert sess.query(T2).one().data == "some data"
> assert sess.query(T2).one().col == u"Some read-only value."
>
> x = sess.query(T2).one()
> x.data = "some new data"
> sess.commit()
> assert sess.query(T2).one().data == "some new data"
>
>
> >


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