This solution didn't work for me, because "polymorphic_on" column was actually a ForeignKey. So when value was null, it worked, but in other cases it didnt.
But I've managed to find a solution.. # Version parent_id = # UUID parent = ... # Version parent_exists = case([(parent_id != None, "revision")], else_="original") __mapper_args__ = {'polymorphic_on': parent_exists} # Revision(Version) __mapper_args__ = {'polymorphic_identity': 'revision'} # Original(Version) __mapper_args__ = {'polymorphic_identity': 'original'} On Friday, May 3, 2013 6:27:14 PM UTC+2, Michael Bayer wrote: > > > On May 3, 2013, at 12:20 PM, Goran Popovic <goranp...@gmail.com<javascript:>> > wrote: > > > Table Versions > > > > # ID > > # PARENT_ID > > # TEXT > > > > If parent_id == Null: > > its ORIGINAL > > > > if parent_id != Null: > > it's REVISION > > > > Is it possible to achieve this with polymorphic_identity? > > > > It seems that polymorphic_identity doesn't support NULL and not NULL > > > > __mapper_args__ = { > > 'polymorphic_identity':'original' > > } > > not built in, but see the recipe at > http://www.sqlalchemy.org/trac/ticket/1409#comment:3 . > > > -- 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 sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy?hl=en. For more options, visit https://groups.google.com/groups/opt_out.