would hit the __eq__() and fail. [ticket:2260]
Does not apply to 0.6.9.
+ - Calling class_mapper() and passing in an object
+ that is not a "type" (i.e. a class that could
+ potentially be mapped) now raises an informative
+ ArgumentError, rather than UnmappedClassError.
+ [ticket:2196]
+
-sql
- Behavioral improvement: empty
conjunctions such as and_() and or_() will be
raise exc.UnmappedInstanceError(instance)
def class_mapper(class_, compile=True):
- """Given a class, return the primary Mapper associated with the key.
+ """Given a class, return the primary :class:`.Mapper` associated
+ with the key.
- Raises UnmappedClassError if no mapping is configured.
+ Raises :class:`.UnmappedClassError` if no mapping is configured
+ on the given class, or :class:`.ArgumentError` if a non-class
+ object is passed.
"""
mapper = class_manager.mapper
except exc.NO_STATE:
+ if not isinstance(class_, type):
+ raise sa_exc.ArgumentError("Class object expected, got '%r'." % class_)
raise exc.UnmappedClassError(class_)
if compile and mapperlib.module._new_mappers:
'addresses':relationship(Address)
})
- assert_raises(sa.orm.exc.UnmappedClassError, sa.orm.configure_mappers)
+ assert_raises_message(
+ sa.orm.exc.UnmappedClassError,
+ "Class 'test.orm._fixtures.Address' is not mapped",
+ sa.orm.configure_mappers)
+
+ def test_unmapped_not_type_error(self):
+ assert_raises_message(
+ sa.exc.ArgumentError,
+ "Class object expected, got '5'.",
+ class_mapper, 5
+ )
def test_unmapped_subclass_error_postmap(self):
users = self.tables.users