raise ArgumentError when incorrect type of prop handed to a composite
Issue #2889
resolved
--- a/test/orm/test_composites.py
+++ b/test/orm/test_composites.py
@@ -6,7 +6,7 @@ from sqlalchemy import Integer, String, ForeignKey, \
from sqlalchemy.testing.schema import Table, Column
from sqlalchemy.orm import mapper, relationship, \
CompositeProperty, aliased
-from sqlalchemy.orm import composite, Session
+from sqlalchemy.orm import composite, Session, configure_mappers
from sqlalchemy.testing import eq_
from sqlalchemy.testing import fixtures
@@ -739,6 +739,24 @@ class ConfigurationTest(fixtures.MappedTest):
})
self._test_roundtrip()
+ def test_check_prop_type(self):
+ edge, Edge, Point = (self.tables.edge,
+ self.classes.Edge,
+ self.classes.Point)
+ mapper(Edge, edge, properties={
+ 'start': sa.orm.composite(Point, (edge.c.x1,), edge.c.y1),
+ })
+ assert_raises_message(
+ sa.exc.ArgumentError,
+ # note that we also are checking that the tuple
+ # renders here, so the "%" operator in the string needs to
+ # apply the tuple also
+ r"Composite expects Column or Column-bound "
+ "attributes/attribute names as "
+ "arguments, got: \(Column",
+ configure_mappers
+ )
+
class ComparatorTest(fixtures.MappedTest, testing.AssertsCompiledSQL):
__dialect__ = 'default'
Comments (4)
-
reporter -
reporter - changed status to resolved
-
reporter I've adjusted that message a bit in 752359936645a6308beb52e77dbdbfad9929a301 / 9c41c2cdc61bcc1b1f7e3 as we support composites to many-to-ones also, so not necessarily Column.
-
reporter - removed milestone
Removing milestone: 0.8.xx (automated comment)
- Log in to comment
see https://github.com/zzzeek/sqlalchemy/commit/c3fb278063022575bbf2cb5e5e48025dd006d9b5#commitcomment-4843381