Good fix, thanks.

And thanks for the first answer too, I had not thought of just using
__table__.c.discriminator.  I was thinking I would need to use
sometable.c.discriminator, which I wasn't sure would work.

Incidentally, I'm finally going to quit using inheritance for cross-
cutting concerns and try mixins instead... In particular, keeping one
set of unique identifiers for trackable objects that can be users,
documents, events, products, etc... so that a note or issue/ticket can
be affixed to any of the above.  But without the mess of having to
draw primary keys for all of those tables from a single parent class
and all the accompanying baggage of inheritance and incurring joins on
more queries than necessary.  Thanks again for the guidance on that in
the past.


On Jun 8, 2:41 pm, Michael Bayer <mike...@zzzcomputing.com> wrote:
> On Jun 8, 2011, at 5:19 PM, Eric Ongerth wrote:
>
> > # Meanwhile, the following way of doing it doesn't work.
> > # But it seems like it would make sense and might be worth enabling.
>
> > class SomeClass(Base):
>
> >    __table__ = Table('sometable', Base.metadata,
> >        Column('id', Integer, primary_key=True),
> >        Column('discriminator', Text),
> >        Column('data', Text))
>
> >    __mapper_args__ = {'polymorphic_on': 'discriminator',
> >                       'polymorphic_identity': 'default'}
>
> "polymorphic_on" someday might be able to handle more than just a column, and 
> there's no dependency-oriented rationale for allowing the string there like 
> there is with relationship(), so its better that it only accept the column 
> for now, which you can do easily enough via 
> {"polymorphic_on":__table__.c.discriminator} above.
>
> > error it causes is not very clear.  The error would be fine if it
> > quoted the piece of code which triggered it, for instance if it said:
> > * AttributeError: 'str' object 'discriminator' has no attribute
> > 'proxy_set'.
>
> we have a canned "columns only" function used by relationship() to check its 
> arguments, while there are probably a lot more places such a checker could 
> go, its additionally affixed to polymorphic_on in r760197daa0c2.

-- 
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 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to