summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2015-01-19 18:31:10 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2015-01-19 18:31:10 -0500
commit234a5b9723fbbb9747c0f9e3917baf8500b73370 (patch)
tree3718d7733c8b54b1faa0b6dfeb42d5b4e2d28d38 /doc
parent26a1d8e77c26d69cdca6e6a41ed7c3526bf27495 (diff)
downloadsqlalchemy-234a5b9723fbbb9747c0f9e3917baf8500b73370.tar.gz
- restore r611883ffb35ca6664649f6328ae8 with additional fixes and an additional test
that is much more specific to #1326
Diffstat (limited to 'doc')
-rw-r--r--doc/build/changelog/changelog_10.rst17
-rw-r--r--doc/build/changelog/migration_10.rst53
2 files changed, 70 insertions, 0 deletions
diff --git a/doc/build/changelog/changelog_10.rst b/doc/build/changelog/changelog_10.rst
index 089c9fafb..79e43e6a3 100644
--- a/doc/build/changelog/changelog_10.rst
+++ b/doc/build/changelog/changelog_10.rst
@@ -23,6 +23,23 @@
on compatibility concerns, see :doc:`/changelog/migration_10`.
.. change::
+ :tags: bug, orm
+ :tickets: 3227, 3242, 1326
+
+ The primary :class:`.Mapper` of a :class:`.Query` is now passed to the
+ :meth:`.Session.get_bind` method when calling upon
+ :meth:`.Query.count`, :meth:`.Query.update`, :meth:`.Query.delete`,
+ as well as queries against mapped columns,
+ :obj:`.column_property` objects, and SQL functions and expressions
+ derived from mapped columns. This allows sessions that rely upon
+ either customized :meth:`.Session.get_bind` schemes or "bound" metadata
+ to work in all relevant cases.
+
+ .. seealso::
+
+ :ref:`bug_3227`
+
+ .. change::
:tags: enhancement, sql
:tickets: 3074
diff --git a/doc/build/changelog/migration_10.rst b/doc/build/changelog/migration_10.rst
index bd878f4cb..c0369d8b8 100644
--- a/doc/build/changelog/migration_10.rst
+++ b/doc/build/changelog/migration_10.rst
@@ -381,6 +381,59 @@ of inheritance-oriented scenarios, including:
:ticket:`3035`
+
+.. _bug_3227:
+
+Session.get_bind() will receive the Mapper in all relevant Query cases
+-----------------------------------------------------------------------
+
+A series of issues were repaired where the :meth:`.Session.get_bind`
+would not receive the primary :class:`.Mapper` of the :class:`.Query`,
+even though this mapper was readily available (the primary mapper is the
+single mapper, or alternatively the first mapper, that is associated with
+a :class:`.Query` object).
+
+The :class:`.Mapper` object, when passed to :meth:`.Session.get_bind`,
+is typically used by sessions that make use of the
+:paramref:`.Session.binds` parameter to associate mappers with a
+series of engines (although in this use case, things frequently
+"worked" in most cases anyway as the bind would be located via the
+mapped table object), or more specifically implement a user-defined
+:meth:`.Session.get_bind` method that provies some pattern of
+selecting engines based on mappers, such as horizontal sharding or a
+so-called "routing" session that routes queries to different backends.
+
+These scenarios include:
+
+* :meth:`.Query.count`::
+
+ session.query(User).count()
+
+* :meth:`.Query.update` and :meth:`.Query.delete`, both for the UPDATE/DELETE
+ statement as well as for the SELECT used by the "fetch" strategy::
+
+ session.query(User).filter(User.id == 15).update(
+ {"name": "foob"}, synchronize_session='fetch')
+
+ session.query(User).filter(User.id == 15).delete(
+ synchronize_session='fetch')
+
+* Queries against individual columns::
+
+ session.query(User.id, User.name).all()
+
+* SQL functions and other expressions against indirect mappings such as
+ :obj:`.column_property`::
+
+ class User(Base):
+ # ...
+
+ score = column_property(func.coalesce(self.tables.users.c.name, None)))
+
+ session.query(func.max(User.score)).scalar()
+
+:ticket:`3227` :ticket:`3242` :ticket:`1326`
+
.. _feature_2963:
.info dictionary improvements