diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-08-02 16:59:06 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-08-02 16:59:06 -0400 |
| commit | dba3ad87b5a762272a11450a18955468d019fe80 (patch) | |
| tree | f1f81abc3a48b00633f7a6a2fef8666ba73059de /lib | |
| parent | e616c2fb3cbc1f2fb7102f3fa666439c688e48b7 (diff) | |
| download | sqlalchemy-dba3ad87b5a762272a11450a18955468d019fe80.tar.gz | |
- Specifying a non-column based argument
for column_mapped_collection, including string,
text() etc., will raise an error message that
specifically asks for a column element, no longer
misleads with incorrect information about
text() or literal(). [ticket:1863]
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/sqlalchemy/orm/collections.py | 2 | ||||
| -rw-r--r-- | lib/sqlalchemy/sql/expression.py | 8 |
2 files changed, 9 insertions, 1 deletions
diff --git a/lib/sqlalchemy/orm/collections.py b/lib/sqlalchemy/orm/collections.py index 0ea17cd8b..b5c4353b3 100644 --- a/lib/sqlalchemy/orm/collections.py +++ b/lib/sqlalchemy/orm/collections.py @@ -129,7 +129,7 @@ def column_mapped_collection(mapping_spec): from sqlalchemy.orm.util import _state_mapper from sqlalchemy.orm.attributes import instance_state - cols = [expression._no_literals(q) for q in util.to_list(mapping_spec)] + cols = [expression._only_column_elements(q) for q in util.to_list(mapping_spec)] if len(cols) == 1: def keyfunc(value): state = instance_state(value) diff --git a/lib/sqlalchemy/sql/expression.py b/lib/sqlalchemy/sql/expression.py index 96147a94a..8a92dba0d 100644 --- a/lib/sqlalchemy/sql/expression.py +++ b/lib/sqlalchemy/sql/expression.py @@ -1035,6 +1035,14 @@ def _no_literals(element): else: return element +def _only_column_elements(element): + if hasattr(element, '__clause_element__'): + element = element.__clause_element__() + if not isinstance(element, ColumnElement): + raise exc.ArgumentError("Column-based expression object expected; " + "got: %r" % element) + return element + def _corresponding_column_or_error(fromclause, column, require_embedded=False): c = fromclause.corresponding_column(column, require_embedded=require_embedded) |
