I am trying to subclass a mapped class from another package for no
other reason than to add a utility method. The polymorphic_on
condition, if it were defined, would have to be 'True'. Example:

class Mapped(declarative_base()):
   # columns

class Utility(Mapped):
   def is_something(self):
      return 'foo'

Encouraged by the fact that session.query(Utility).first() works, I
proceeded and got an exception.

The error is

FlushError: Attempting to flush an item of type <Utility> on
collection 'Something.mapped', which is not the expected type.
Configure mapper 'Mapper|User|user' to load this subtype
polymorphically, or set enable_typechecks=False to allow subtypes.
Mismatched typeloading may cause bi-directional relationships
(backrefs) to not function properly.

I'm starting to think I should just monkey patch the original class or
just pass the Mapped() into utility()... is that the best way?

Thanks!

Daniel

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalch...@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.

Reply via email to