Thanks Michael for your answer. Shame on me, that I did not find this point in documentation.
But such behaviour seems strange to me. Why should I specify these parameters in anchestors, specify anchestors in a child class and then explicitly describe my arguments once more in a child class? I would prefer if __mapper_args__ would be merged automatically in the standard inheritance order. On 13 фев, 23:30, Michael Bayer <mike...@zzzcomputing.com> wrote: > On Feb 13, 2011, at 1:39 PM, Andrey Gladilin wrote: > > > > > I am trying to create a version column which would use values from a > > single postgresql sequence. > > > record_versions_id_seq = Sequence('record_versions_id_seq') > > > class TimestampMixin(object): > > created_at = Column(DateTime, default=func.now()) > > record_version = Column(Integer, nullable=False, > > default=func.nextval("record_versions_id_seq")) > > > __mapper_args__ = { > > 'version_id_col': record_version, > > 'version_id_generator': lambda v: > > func.nextval("record_versions_id_seq") > > } > > > class Team(Base, NameMixin, TimestampMixin): > > __tablename__ = 'teams' > > id = Column(Integer, primary_key=True) > > > There are other tables like Team inheriting TimestampMixin. And here I > > have two problems: > > > 1. Decribed code does not work for update. I.e when I update the > > record from Team, the record_version column value is not getting > > changed. So to workaround this problem I have to explicitly specify > > __mapper_args__ in Team class. > > if Base or NameMixin is also modifying __mapper_args__, those will override > what TimestampMixin returns. The __mapper_args__ from different mixins need > to be combined manually for the final product. Some background > athttp://www.sqlalchemy.org/docs/orm/extensions/declarative.html#combin... > > > 2. Code lambda v: func.nextval("record_versions_id_seq") does not > > work. I guess this code is incorrect, so could you help me to create a > > correct one please? > > you'd need to execute the function through a connection, and you can use the > Sequence object directly: > > lambda v: some_engine.execute(record_versions_id_seq) -- 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.