python - sqlalchemy polymorhic_identity not working -


I am trying to use polymorphic_on on a Python class with many warriors:

  Engine = Create_engine ('mysql: // xxx: yyy @ localhost: 3306 / zzz? Charset = utf8 and use_unicode = 0', pool_recycle = 3600, echo = true) base = declarative_base () class AbstractPersistent (object): Version = column ('version', integer) last_modified_by = column ('LAST_MODIFIED_BY', string (255)) last_modified_date = column ('LAST_MODIFIED_DATE', date) Created_by = column ('CREATED_BY', string (255)) Created_data = column ('CREATED_DATE' month Category: abstract abstract (abstract): eid = Column ('ENTERPRISE_ID', string (255)) Title = column ('TITLE', string (255)) Description = column ('Description', string (255)) Category AbstractContainer (Named abstract): __tablename__ = 'CM_MEMBER_CONTAINER_T' id = column ('MEMBER_CONTAINER_ID', integer, primary_key = true) discriminator = column ('CLASS_DISCR', string (100)) __mapar_garz__ = {'polymorphic_on': differentiation} square cursor ( Base, sarctinineer): __mapper_arms__ = {'polymorphic_idti': 'org.sakaiproject.coursemanagement.impl.CourseSetCmImpl'} As you can see, all the columns of her parents in  CosetSet  and column  CLASS_DISCR  set to  'Org.sakaiproject.coursemanagement.impl.CourseSetCmImpl' . 

But when all this Coset :

  session = session maker (bind = engine) session = session () course_sets = session .query Cursetts). All () prints (course_set)  

gives all entries of 'CM_MEMBER_CONTAINER_T' , but I want only those people with whom CLASS_DISCR < / Code> set to 'org.sakaiproject.coursemanagement.impl.CourseSetCmImpl'

Any thoughts?

thanks, this is the answer:

sarcatain er is not mapped, it has a mixer, so its __mapper_arag __ is not used unless the subclass of base Is not implemented, which starts a declarative mapping. Your only mapped class is the Curset , which has its own __aper_gars___ , which is override of AbstractContainer - it is ignored is.

To combine a __merper_graz __ from a mapped class with a mixer, the example uses __ table_args __ , but The same concept of creating a complete dictionary argument as well as __mapper_gues___ .


Comments