the two declared_attr approach on the mixin is fine for both.
On Nov 6, 2012, at 6:39 PM, John Anderson wrote: > I'm using 0.8 but the library itself is open source so it might be good to > support older versions. Does the 0.7 version work for both? Or is the > mapper hack the best way for backwards compatibility? > > On Tuesday, November 6, 2012 7:42:17 PM UTC-3, John Anderson wrote: > I have a mixin that declares a primary key but would like to dynamically > override the name of it. > > So for instance this is the base: > > class BaseModel(object): > @declared_attr > def pk(self): > return sa.Column(sa.Integer, autoincrement=True, primary_key=True) > > but in some circumstances people want to use my mixin but declare the primary > key property as id instead. > > So I want to be able to do something class > > class SubClass(BaseModel): > _idAttribute = 'id' > > and have it use id in the database and has the class property to reference > instead of pk. > > > Is this possible? > > > -- > You received this message because you are subscribed to the Google Groups > "sqlalchemy" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/sqlalchemy/-/d0v7hdxF9FMJ. > 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. -- 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.
