diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2011-03-20 12:49:28 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2011-03-20 12:49:28 -0400 |
commit | 90335a89a98df23db7a3ae1233eb4fbb5743d2e8 (patch) | |
tree | 9a4ac236f83696709bd355dcac22552aeb177694 /lib/sqlalchemy/sql/expression.py | |
parent | 75c78aa714ca55818f0ba12a67cf2f77927b68f7 (diff) | |
download | sqlalchemy-90335a89a98df23db7a3ae1233eb4fbb5743d2e8.tar.gz |
- Added new generic function "next_value()", accepts
a Sequence object as its argument and renders the
appropriate "next value" generation string on the
target platform, if supported. Also provides
".next_value()" method on Sequence itself.
[ticket:2085]
- added tests for all the conditions described
in [ticket:2085]
- postgresql dialect will exec/compile a Sequence
that has "optional=True". the optional flag is now only
checked specifically in the context of a Table primary key
evaulation.
- func.next_value() or other SQL expression can
be embedded directly into an insert() construct,
and if implicit or explicit "returning" is used
in conjunction with a primary key column,
the newly generated value will be present in
result.inserted_primary_key. [ticket:2084]
Diffstat (limited to 'lib/sqlalchemy/sql/expression.py')
-rw-r--r-- | lib/sqlalchemy/sql/expression.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/sqlalchemy/sql/expression.py b/lib/sqlalchemy/sql/expression.py index 9aed957d2..d49f12150 100644 --- a/lib/sqlalchemy/sql/expression.py +++ b/lib/sqlalchemy/sql/expression.py @@ -1178,14 +1178,16 @@ def _column_as_key(element): return element.key def _literal_as_text(element): - if hasattr(element, '__clause_element__'): + if isinstance(element, Visitable): + return element + elif hasattr(element, '__clause_element__'): return element.__clause_element__() elif isinstance(element, basestring): return _TextClause(unicode(element)) - elif not isinstance(element, Visitable): - raise exc.ArgumentError("SQL expression object or string expected.") else: - return element + raise exc.ArgumentError( + "SQL expression object or string expected." + ) def _clause_element_as_expr(element): if hasattr(element, '__clause_element__'): |