summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql
diff options
context:
space:
mode:
authorGord Thompson <gord@gordthompson.com>2020-08-01 15:56:12 -0600
committerMike Bayer <mike_mp@zzzcomputing.com>2020-08-19 11:05:52 -0400
commit0c7a867ac73f1ed0ecfa134e907654fd4f7c084b (patch)
treec645f7514e9f6b977b2440413b6572b40c0edbd5 /lib/sqlalchemy/sql
parent0901190bb440580f0664fe3f6310173762b908e0 (diff)
downloadsqlalchemy-0c7a867ac73f1ed0ecfa134e907654fd4f7c084b.tar.gz
Add JSON support for mssql
Added support for the :class:`_types.JSON` datatype on the SQL Server dialect using the :class:`_mssql.JSON` implementation, which implements SQL Server's JSON functionality against the ``NVARCHAR(max)`` datatype as per SQL Server documentation. Implementation courtesy Gord Thompson. Fixes: #4384 Change-Id: I28af79a4d8fafaa68ea032228609bba727784f18
Diffstat (limited to 'lib/sqlalchemy/sql')
-rw-r--r--lib/sqlalchemy/sql/sqltypes.py21
1 files changed, 17 insertions, 4 deletions
diff --git a/lib/sqlalchemy/sql/sqltypes.py b/lib/sqlalchemy/sql/sqltypes.py
index fd85d6d30..f1063b71a 100644
--- a/lib/sqlalchemy/sql/sqltypes.py
+++ b/lib/sqlalchemy/sql/sqltypes.py
@@ -2034,11 +2034,17 @@ class JSON(Indexable, TypeEngine):
JSON types. Since it supports JSON SQL operations, it only
works on backends that have an actual JSON type, currently:
- * PostgreSQL
+ * PostgreSQL - see :class:`_postgresql.JSON` and
+ :class:`_postgresql.JSONB` for backend-specific notes
- * MySQL as of version 5.7 (MariaDB as of the 10.2 series does not)
+ * MySQL as of version 5.7 (MariaDB as of the 10.2 series does not) - see
+ :class:`_mysql.JSON` for backend-specific notes
- * SQLite as of version 3.9
+ * SQLite as of version 3.9 - see :class:`_sqlite.JSON` for
+ backend-specific notes
+
+ * Microsoft SQL Server 2016 and later - see :class:`_mssql.JSON` for
+ backend-specific notes
:class:`_types.JSON` is part of the Core in support of the growing
popularity of native JSON datatypes.
@@ -2452,7 +2458,14 @@ class JSON(Indexable, TypeEngine):
def as_json(self):
"""Cast an indexed value as JSON.
- This is the default behavior of indexed elements in any case.
+ e.g.::
+
+ stmt = select([
+ mytable.c.json_column['some_data'].as_json()
+ ])
+
+ This is typically the default behavior of indexed elements in any
+ case.
Note that comparison of full JSON structures may not be
supported by all backends.