summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2010-12-30 12:14:32 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2010-12-30 12:14:32 -0500
commit74b7bd4365c429425dd944c3dee8681a1ca6abdb (patch)
tree1b72a0eb6fda23c1d361ddcc2175cf3f3bdcbf6c /lib/sqlalchemy
parentb1c90de4494369c7c901f9f3e5e21271656024c5 (diff)
downloadsqlalchemy-74b7bd4365c429425dd944c3dee8681a1ca6abdb.tar.gz
- A little more verbiage to the "primaryjoin" error,
in an unusual condition that the join condition "works" for viewonly but doesn't work for non-viewonly, and foreign_keys wasn't used - adds "foreign_keys" to the suggestion. Also add "foreign_keys" to the suggestion for the generic "direction" error.
Diffstat (limited to 'lib/sqlalchemy')
-rw-r--r--lib/sqlalchemy/orm/properties.py30
1 files changed, 22 insertions, 8 deletions
diff --git a/lib/sqlalchemy/orm/properties.py b/lib/sqlalchemy/orm/properties.py
index c7aa0eeea..0057f5a41 100644
--- a/lib/sqlalchemy/orm/properties.py
+++ b/lib/sqlalchemy/orm/properties.py
@@ -828,16 +828,29 @@ class RelationshipProperty(StrategizedProperty):
if not self.viewonly and criterion_as_pairs(join_condition,
consider_as_foreign_keys=self._user_defined_foreign_keys,
any_operator=True):
- raise sa_exc.ArgumentError("Could not locate any "
- "equated, locally mapped column pairs for %s "
- "condition '%s' on relationship %s. For more "
- "relaxed rules on join conditions, the "
- "relationship may be marked as viewonly=True."
- % (
+
+ err = "Could not locate any "\
+ "foreign-key-equated, locally mapped column "\
+ "pairs for %s "\
+ "condition '%s' on relationship %s." % (
primary and 'primaryjoin' or 'secondaryjoin',
join_condition,
self
- ))
+ )
+
+ if not self._user_defined_foreign_keys:
+ err += " Ensure that the "\
+ "referencing Column objects have a "\
+ "ForeignKey present, or are otherwise part "\
+ "of a ForeignKeyConstraint on their parent "\
+ "Table, or specify the foreign_keys parameter "\
+ "to this relationship."
+
+ err += " For more "\
+ "relaxed rules on join conditions, the "\
+ "relationship may be marked as viewonly=True."
+
+ raise sa_exc.ArgumentError(err)
else:
if self._user_defined_foreign_keys:
raise sa_exc.ArgumentError("Could not determine "
@@ -864,7 +877,8 @@ class RelationshipProperty(StrategizedProperty):
"referencing Column objects have a "
"ForeignKey present, or are otherwise part "
"of a ForeignKeyConstraint on their parent "
- "Table."
+ "Table, or specify the foreign_keys parameter "
+ "to this relationship."
% (
primary and 'primaryjoin' or 'secondaryjoin',
join_condition,