summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2010-04-16 17:01:50 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2010-04-16 17:01:50 -0400
commit3bd09e291b8c9920b043f41438c636bf5bbaeef3 (patch)
treef75b00c5f9ffbb6183a6e74aa996638048c970f1
parentb437bb213221e98fd5909a9082df8b4b6a25fc3f (diff)
downloadsqlalchemy-3bd09e291b8c9920b043f41438c636bf5bbaeef3.tar.gz
when raising about columns not present, include the name of the property it's trying to configure,
to eliminate confusion over attributes not properly placed inside of a relationship().
-rw-r--r--lib/sqlalchemy/orm/mapper.py11
-rw-r--r--test/orm/test_mapper.py2
-rw-r--r--test/orm/test_query.py2
3 files changed, 9 insertions, 6 deletions
diff --git a/lib/sqlalchemy/orm/mapper.py b/lib/sqlalchemy/orm/mapper.py
index 673e16b29..7a4230099 100644
--- a/lib/sqlalchemy/orm/mapper.py
+++ b/lib/sqlalchemy/orm/mapper.py
@@ -560,18 +560,21 @@ class Mapper(object):
self.mapped_table._reset_exported()
mc = self.mapped_table.corresponding_column(c)
if mc is None:
- raise sa_exc.ArgumentError("Column '%s' is not represented in mapper's table. "
+ raise sa_exc.ArgumentError("When configuring property '%s' on %s, "
+ "column '%s' is not represented in the mapper's table. "
"Use the `column_property()` function to force this column "
- "to be mapped as a read-only attribute." % c)
+ "to be mapped as a read-only attribute." % (key, self, c))
mapped_column.append(mc)
prop = ColumnProperty(*mapped_column)
else:
- raise sa_exc.ArgumentError("WARNING: column '%s' conflicts with property '%r'. "
+ raise sa_exc.ArgumentError("WARNING: when configuring property '%s' on %s, column '%s' "
+ "conflicts with property '%r'. "
"To resolve this, map the column to the class under a different "
"name in the 'properties' dictionary. Or, to remove all awareness "
"of the column entirely (including its availability as a foreign key), "
"use the 'include_properties' or 'exclude_properties' mapper arguments "
- "to control specifically which table columns get mapped." % (column.key, prop))
+ "to control specifically which table columns get mapped." %
+ (key, self, column.key, prop))
if isinstance(prop, ColumnProperty):
col = self.mapped_table.corresponding_column(prop.columns[0])
diff --git a/test/orm/test_mapper.py b/test/orm/test_mapper.py
index ef9214a8b..e609e5ba0 100644
--- a/test/orm/test_mapper.py
+++ b/test/orm/test_mapper.py
@@ -157,7 +157,7 @@ class MapperTest(_fixtures.FixtureTest):
@testing.resolve_artifact_names
def test_column_not_present(self):
- assert_raises_message(sa.exc.ArgumentError, "not represented in mapper's table", mapper, User, users, properties={
+ assert_raises_message(sa.exc.ArgumentError, "not represented in the mapper's table", mapper, User, users, properties={
'foo':addresses.c.user_id
})
diff --git a/test/orm/test_query.py b/test/orm/test_query.py
index 89b66fd86..ceb78ad1f 100644
--- a/test/orm/test_query.py
+++ b/test/orm/test_query.py
@@ -3750,7 +3750,7 @@ class ExternalColumnsTest(QueryTest):
def test_external_columns_bad(self):
- assert_raises_message(sa_exc.ArgumentError, "not represented in mapper's table", mapper, User, users, properties={
+ assert_raises_message(sa_exc.ArgumentError, "not represented in the mapper's table", mapper, User, users, properties={
'concat': (users.c.id * 2),
})
clear_mappers()