We're using single table inheritence in one of our projects but we have
some obsolete rows that are each mapped to their own python class.
If we remove the obsolete classes, when we try and do:
session.query(TheBaseClass)
...we get:
File
"/usr/lib/python2.5/site-packages/SQLAlchemy-0.5.5-py2.5.egg/sqlalchemy/orm/mapper.py",
line 1742, in configure_subclass_mapper
raise AssertionError("No such polymorphic_identity %r is defined" %
discriminator)
AssertionError: No such polymorphic_identity 'TheClassName' is defined
Is there any way to phrase that query as "just ignore rows where no
polymorphic mapper can be found"?
If not, I guess I need to do session.query(TheClassName).delete() before
I remove the code, right?
cheers,
Chris
it would be best to remove the rows. Otherwise, you'd need to filter()
your queries on "TheBaseClass.type != 'TheClassName'" to prevent those
rows from coming in.
This is a common problem we have all the time here.
If that's so, could a flag not be added somewhere (waves hands idly) in
the process that said "ignore or emit warnings for rows with no matching
class"?
Chris
--
Simplistix - Content Management, Batch Processing & Python Consulting
- http://www.simplistix.co.uk