diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2015-06-10 23:38:15 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2016-06-02 14:41:31 -0400 |
commit | e28b44813721f258bf76fb7c85bf5559ecd219ec (patch) | |
tree | 7929c90ba8d19b75ca9b33a04e8b65254ccb0899 /doc/build | |
parent | 31699bd1866bbfc36f1501e5e1b54d3c06cf3b4c (diff) | |
download | sqlalchemy-e28b44813721f258bf76fb7c85bf5559ecd219ec.tar.gz |
Add an init_scalar event for attributes
This allows us to build default-setting recipes such
as one that allows us to actively read column-level
defaults. An example suite is also added.
Change-Id: I7b022d52cc89526132d5bc4201ac27fea4cf088d
Fixes: #1311
Diffstat (limited to 'doc/build')
-rw-r--r-- | doc/build/changelog/changelog_11.rst | 13 | ||||
-rw-r--r-- | doc/build/changelog/migration_11.rst | 25 |
2 files changed, 38 insertions, 0 deletions
diff --git a/doc/build/changelog/changelog_11.rst b/doc/build/changelog/changelog_11.rst index 898b8a0ba..627505482 100644 --- a/doc/build/changelog/changelog_11.rst +++ b/doc/build/changelog/changelog_11.rst @@ -22,6 +22,19 @@ :version: 1.1.0b1 .. change:: + :tags: feature, orm + :tickets: 1311 + + Added new event :meth:`.AttributeEvents.init_scalar`, as well + as a new example suite illustrating its use. This event can be used + to provide a Core-generated default value to a Python-side attribute + before the object is persisted. + + .. seealso:: + + :ref:`change_1311` + + .. change:: :tags: feature, postgresql :tickets: 3720 diff --git a/doc/build/changelog/migration_11.rst b/doc/build/changelog/migration_11.rst index 0d94f35e9..479681798 100644 --- a/doc/build/changelog/migration_11.rst +++ b/doc/build/changelog/migration_11.rst @@ -154,6 +154,31 @@ recipe illustrating how to replace the strong identity map. :ticket:`2677` +.. _change_1311: + +New init_scalar() event intercepts default values at ORM level +-------------------------------------------------------------- + +The ORM produces a value of ``None`` when an attribute that has not been +set is first accessed, for a non-persistent object:: + + >>> obj = MyObj() + >>> obj.some_value + None + +There's a use case for this in-Python value to correspond to that of a +Core-generated default value, even before the object is persisted. +To suit this use case a new event :meth:`.AttributeEvents.init_scalar` +is added. The new example ``active_column_defaults.py`` at +:ref:`examples_instrumentation` illustrates a sample use, so the effect +can instead be:: + + >>> obj = MyObj() + >>> obj.some_value + "my default" + +:ticket:`1311` + .. _change_3499: Changes regarding "unhashable" types |