summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2015-08-17 17:04:33 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2015-08-17 17:12:16 -0400
commitd14a4b480c3b43885707e4a6e2466589971ff4d5 (patch)
treefab9267e749501c7b32c9e6e9f9f8429ef2b5644 /lib/sqlalchemy/sql
parentceeb033054f09db3eccbde3fad1941ec42919a54 (diff)
downloadsqlalchemy-d14a4b480c3b43885707e4a6e2466589971ff4d5.tar.gz
- merge of ticket_3514 None-handling branch
- Fixes to the ORM and to the postgresql JSON type regarding the ``None`` constant in conjunction with the Postgresql :class:`.JSON` type. When the :paramref:`.JSON.none_as_null` flag is left at its default value of ``False``, the ORM will now correctly insert the Json "'null'" string into the column whenever the value on the ORM object is set to the value ``None`` or when the value ``None`` is used with :meth:`.Session.bulk_insert_mappings`, **including** if the column has a default or server default on it. This makes use of a new type-level flag "evaluates_none" which is implemented by the JSON type based on the none_as_null flag. fixes #3514 - Added a new constant :attr:`.postgresql.JSON.NULL`, indicating that the JSON NULL value should be used for a value regardless of other settings. part of fixes #3514
Diffstat (limited to 'lib/sqlalchemy/sql')
-rw-r--r--lib/sqlalchemy/sql/type_api.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/sqlalchemy/sql/type_api.py b/lib/sqlalchemy/sql/type_api.py
index 8f502ac02..701e2a44a 100644
--- a/lib/sqlalchemy/sql/type_api.py
+++ b/lib/sqlalchemy/sql/type_api.py
@@ -129,6 +129,19 @@ class TypeEngine(Visitable):
"""
+ evaluates_none = False
+ """If True, the Python constant ``None`` is considered to be handled
+ explicitly by this type.
+
+ The ORM will use this flag to ensure that a positive value of ``None``
+ is definitely passed to the backend, ignoring whether or not there
+ are Python or server side defaults on this column.
+
+ .. versionadded:: 1.1
+
+
+ """
+
def compare_against_backend(self, dialect, conn_type):
"""Compare this type against the given backend type.