We have tried suggested, but: field 'modified' exists in both parent and child tables, when we redefined property 'modified' in mapper with something like this: mapper(Child, child_table, properties={'modified' = child_table.c.modified, ...}), modified field still returned value from parent's table. We also tried to add property to class like this:
class Parent(object) : table = None ... def _fieldFromQuery(self, field): if not self.table: return None return Session.object_session(self).execute(select([getattr (self.table.c, field)]).where(self.table.c.id==self.id)).scalar() def _modified(self): return self._fieldFromQuery("modified") def _modified_by(self): return self._fieldFromQuery("modified_by") modified = property(_modified) modified_by = property(_modified_by) where self.table is assigned just before mapper is created. Mapper itself again redefined attribute 'modified' and 'modified_by' so we were back to starting problem. On Oct 29, 3:56 pm, "Michael Bayer" <mike...@zzzcomputing.com> wrote: > bojanb wrote: > > > Hi, > > > Can I have identical column names in both parent and child classes > > that are part of a joined-table inheritance? These are simply created, > > created_by, modified, modified_by columns that are populated by > > defaults defined for them (ie. default, server_default, onupdate). > > > The values are written to the database correctly, but I have a problem > > reading them because parent's column values override child values. So, > > if the parent has null values for modified, modified_by and the child > > some actual values, ORM returns None for child.modified and > > child.modified_by. > > use the "properties" dictionary to mapper to redefine the names. or the > declarative equivalent. > seehttp://www.sqlalchemy.org/docs/05/mappers.html#customizing-column-pro... > > > > > Suggestions? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---