This is ticket #2472 and is resolved for 0.8, where this script returns a
"column conflict" error. The issue is described at
http://docs.sqlalchemy.org/en/latest/orm/extensions/declarative.html#resolving-column-conflicts
and in this case, using 0.8 only, is resolved using this form:
class Mixin:
@declared_attr
def mixed(cls):
return cls.__table__.c.get('mixed', Column("mixed", types.String(80),
default=""))
in 0.7, the mixin can't be used this way as declarative doesn't know how to
resolve the apparent conflict of both MixedFirst and MixedSecond independently
specifying a column named "mixed".
On Oct 10, 2012, at 2:29 PM, missingfaktor wrote:
> Python version: 3.2.3
> sqlalchemy version: 0.7.9
>
> (Please see the attached source file.) I have a class Simple, which has two
> subclasses - MixedFirst and MixedSecond. These two subclasses have a field in
> common, namely, mixed. So I have put it in a separate class (a mixin) named
> Mixin, which both MixedFirst and MixedSecond inherit from. I am using single
> table inheritance to map this to database.
>
> I am adding one instance each of Simple, MixedFirst and MixedSecond twice.
> Once in add_rows(), and once in run_stuff().
>
> When I query the table and polymorphically load all the instances, the
> "mixed" field on some objects contains a value of type sqlalchemy Column,
> which is incorrect. Here are some more specific observations:
> - The rows added in run_stuff() work as expected (even if you comment out the
> inserts in add_rows).
> - The rows added in add_rows() show up the error of ".mixed" ending up
> showing the wrong value (that of a SA column instead of the field value).
> - If we reorder the declaration of MixedFirst and MixedSecond, the error of
> ".mixed" switches over to the instance of the class that gets declared later.
>
> I also tried using declared_attr as suggested here -
> http://docs.sqlalchemy.org/ru/latest/orm/extensions/declarative.html, but
> that made no difference.
>
> This looks like a bug but I would first like to confirm it before filing a
> bug report.
>
> --
> Cheers,
> Rahul.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "sqlalchemy" group.
> To post to this group, send email to [email protected].
> 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.
> <resetdb.py>
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected].
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.