diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-12-30 12:14:32 -0500 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-12-30 12:14:32 -0500 |
| commit | 74b7bd4365c429425dd944c3dee8681a1ca6abdb (patch) | |
| tree | 1b72a0eb6fda23c1d361ddcc2175cf3f3bdcbf6c /lib/sqlalchemy | |
| parent | b1c90de4494369c7c901f9f3e5e21271656024c5 (diff) | |
| download | sqlalchemy-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.py | 30 |
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, |
