Hi all,
I'm ultimately trying to have different default values for the same column.
Following the documentation, the @declared_attr.cacading decorator seems to
be the best approach.
Here's my code:
class HasSomeAttribute(object):
@declared_attr.cascading
def type(cls):
if has_inherited_table(cls):
if cls.__name__ == 'MySubClass1':
return db.Column(db.Integer, default=1)
else:
return db.Column(db.Integer, default=2)
else:
return db.Column(db.Integer, default=0)
class MyClass(HasSomeAttribute, db.Model):
__tablename__ = 'people4l2'
id = db.Column(db.Integer, primary_key=True)
class MySubClass1(MyClass):
pass
class MySubClass2(MyClass):
pass
I iterated quite a few times over this but I'm systematically getting this
error:
ArgumentError: Column 'type' on class <class '__main__.MySubClass1'> conflicts
with existing column 'people4l2.type'
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.