@declared_attr cannot take in column_property

Issue #3575 invalid
Daniel Kassen created an issue

In an effort to force multiple level polymorphism out of sqlalchemy, my colleague has devised a clever way to make multiple types of collections. To do this he creates a collections base which inherits from the 'polymorphic_on' class. All the attributes declared in this collection base class are decorated with @declared_attr, including the id, mapper_args, and title. the 'title' is inherited from the polymorphic class and is simply a unicode text type column. But because it is inherited, and redeclared in this new collections class, we get the following warning:

SAWarning: Implicitly combining column assets.title with column collections.title under attribute 'title'. Please configure one or more attributes for these same-named columns explicitly.

I tried fixing this warning by wrapping the Column object being returned with the column_property method(?). Apparently @declared_attr cannot take a column_property object, and if I'm guessing right thinking that a column_property(A, B) is a column of type A with the properties of B, then this should be fixed.

It asks me to configure the column explicitly, and then complains when I do.

Comments (1)

  1. Mike Bayer repo owner

    this warning is by design and tells you about an important mis-configuration which is when two columns are implicitly set to share the same value. There's no code example here so there's nothing for me to look at or do. for documentation on column_property with declared_attr please see the notes at http://docs.sqlalchemy.org/en/rel_1_0/orm/extensions/declarative/mixins.html#mixing-in-deferred-column-property-and-other-mapperproperty-classes.

    when posting bugs, please include source code, see the guidelines at http://stackoverflow.com/help/mcve thanks!

  2. Log in to comment