@@ -1904,7 +1904,7 @@ class JSON(Indexable, TypeEngine[Any]):
1904
1904
with engine.connect() as conn:
1905
1905
conn.execute(
1906
1906
data_table.insert(),
1907
- data = {"key1": "value1", "key2": "value2"}
1907
+ {" data": {"key1": "value1", "key2": "value2"} }
1908
1908
)
1909
1909
1910
1910
**JSON-Specific Expression Operators**
@@ -2000,20 +2000,22 @@ class JSON(Indexable, TypeEngine[Any]):
2000
2000
2001
2001
**Support for JSON null vs. SQL NULL**
2002
2002
2003
- When working with NULL values, the :class:`_types.JSON`
2004
- type recommends the
2003
+ When working with NULL values, the :class:`_types.JSON` type recommends the
2005
2004
use of two specific constants in order to differentiate between a column
2006
- that evaluates to SQL NULL, e.g. no value, vs. the JSON-encoded string
2007
- of ``"null"``. To insert or select against a value that is SQL NULL,
2008
- use the constant :func:`.null`::
2005
+ that evaluates to SQL NULL, e.g. no value, vs. the JSON-encoded string of
2006
+ ``"null"``. To insert or select against a value that is SQL NULL, use the
2007
+ constant :func:`.null`. This symbol may be passed as a parameter value
2008
+ specifically when using the :class:`_types.JSON` datatype, which contains
2009
+ special logic that interprets this symbol to mean that the column value
2010
+ should be SQL NULL as opposed to JSON ``"null"``::
2009
2011
2010
2012
from sqlalchemy import null
2011
- conn.execute(table.insert(), json_value= null())
2013
+ conn.execute(table.insert(), {" json_value": null()} )
2012
2014
2013
2015
To insert or select against a value that is JSON ``"null"``, use the
2014
2016
constant :attr:`_types.JSON.NULL`::
2015
2017
2016
- conn.execute(table.insert(), json_value= JSON.NULL)
2018
+ conn.execute(table.insert(), {" json_value": JSON.NULL} )
2017
2019
2018
2020
The :class:`_types.JSON` type supports a flag
2019
2021
:paramref:`_types.JSON.none_as_null` which when set to True will result
@@ -2114,12 +2116,14 @@ def __init__(self, none_as_null=False):
2114
2116
"""Construct a :class:`_types.JSON` type.
2115
2117
2116
2118
:param none_as_null=False: if True, persist the value ``None`` as a
2117
- SQL NULL value, not the JSON encoding of ``null``. Note that
2118
- when this flag is False, the :func:`.null` construct can still
2119
- be used to persist a NULL value::
2119
+ SQL NULL value, not the JSON encoding of ``null``. Note that when this
2120
+ flag is False, the :func:`.null` construct can still be used to
2121
+ persist a NULL value, which may be passed directly as a parameter
2122
+ value that is specially interpreted by the :class:`_types.JSON` type
2123
+ as SQL NULL::
2120
2124
2121
2125
from sqlalchemy import null
2122
- conn.execute(table.insert(), data= null())
2126
+ conn.execute(table.insert(), {" data": null()} )
2123
2127
2124
2128
.. note::
2125
2129
@@ -2461,7 +2465,7 @@ class ARRAY(
2461
2465
2462
2466
connection.execute(
2463
2467
mytable.insert(),
2464
- data= [1,2,3]
2468
+ {" data": [1,2,3]}
2465
2469
)
2466
2470
2467
2471
The :class:`_types.ARRAY` type can be constructed given a fixed number
0 commit comments