diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2016-10-05 10:57:30 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2016-10-05 12:11:53 -0400 |
| commit | 09b685b24b19636e11169c181b45333f9739ca35 (patch) | |
| tree | 12f176c23ffb9f9f9de75e4fdb07ec8eed5611cb /doc | |
| parent | 20384e894577bc6cd7e686a71e6e859207565d00 (diff) | |
| download | sqlalchemy-09b685b24b19636e11169c181b45333f9739ca35.tar.gz | |
Check for __clause_element__() in ORM insert/update
ORM attributes can now be assigned any object that is has a
``__clause_element__()`` attribute, which will result in inline
SQL the way any :class:`.ClauseElement` class does. This covers other
mapped attributes not otherwise transformed by further expression
constructs.
As part of this, it was considered that we could add
__clause_element__() to ClauseElement, however this causes endless loops
in a "while" pattern and this pattern has been identified in third
party libraries. Add a test to ensure we never make that change.
Change-Id: I9e15b3f1c4883fd3909acbf7dc81d034c6e3ce1d
Fixes: #3802
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/build/changelog/changelog_11.rst | 10 | ||||
| -rw-r--r-- | doc/build/changelog/migration_11.rst | 4 |
2 files changed, 12 insertions, 2 deletions
diff --git a/doc/build/changelog/changelog_11.rst b/doc/build/changelog/changelog_11.rst index afdade444..d7046dee3 100644 --- a/doc/build/changelog/changelog_11.rst +++ b/doc/build/changelog/changelog_11.rst @@ -22,6 +22,16 @@ :version: 1.1.0 .. change:: + :tags: bug, orm + :tickets: 3802 + + ORM attributes can now be assigned any object that is has a + ``__clause_element__()`` attribute, which will result in inline + SQL the way any :class:`.ClauseElement` class does. This covers other + mapped attributes not otherwise transformed by further expression + constructs. + + .. change:: :tags: feature, orm :tickets: 3812 diff --git a/doc/build/changelog/migration_11.rst b/doc/build/changelog/migration_11.rst index 978e6abf1..560872fc9 100644 --- a/doc/build/changelog/migration_11.rst +++ b/doc/build/changelog/migration_11.rst @@ -214,7 +214,8 @@ Specific checks added for passing mapped classes, instances as SQL literals The typing system now has specific checks for passing of SQLAlchemy "inspectable" objects in contexts where they would otherwise be handled as literal values. Any SQLAlchemy built-in object that is legal to pass as a -SQL value includes a method ``__clause_element__()`` which provides a +SQL value (which is not already a :class:`.ClauseElement` instance) +includes a method ``__clause_element__()`` which provides a valid SQL expression for that object. For SQLAlchemy objects that don't provide this, such as mapped classes, mappers, and mapped instances, a more informative error message is emitted rather than @@ -2210,7 +2211,6 @@ the issue. :ticket:`3809` - .. _change_2528: A UNION or similar of SELECTs with LIMIT/OFFSET/ORDER BY now parenthesizes the embedded selects |
