cant insert NULL into a json column if column is present
See original GitHub issueMigrated issue, originally created by Michael Bayer (@zzzeek)
the serializer grabs None if it is present. for backwards compat we should support null() which currently also blows up:
from sqlalchemy import create_engine, Column, Table, MetaData, func, select, null
from sqlalchemy.dialects.postgresql import JSON
e = create_engine("postgresql://scott:tiger@localhost/test", echo='debug')
c = e.connect()
t = c.begin()
table = Table('json_test', MetaData(), Column('data', JSON))
table.create(c)
c.execute(table.insert(), [{"data": {"foo": "bar"}}, {"data": None}])
assert c.scalar(
select([func.count('*')]).
select_from(table).where(table.c.data == null()))
# probable workaround, also fails to invoke
#c.execute(table.insert(), [{"data": {"foo": "bar"}}, {"data": null()}])
Issue Analytics
- State:
- Created 9 years ago
- Comments:5
Top Results From Across the Web
mysql JSON_SET can't insert into column with NULL value(5.7+)
Tried to set the column default to {} , but it is not allowed. My current work around is to set NULL to...
Read more >Mysql temp table insert from json can't handle null values
I manage to detect if the value is null using an in-line IF statement, then I try to cast an actual SQL NULL...
Read more >ORA-01400: cannot insert null into (string) | TekStream Solutions
According to Oracle, a null value can appear in columns of any datatype as long as it is not set to the value...
Read more >Solve common issues with JSON in SQL Server
Answer. JSON_VALUE is designed to return small scalar values. Generally the function returns NULL instead of an overflow error. If you want to...
Read more >Handling JSON null and empty arrays and objects - IBM
Null values · id - If the property is defined as nillable in the schema, then it will be set to null. ·...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Michael Bayer (@zzzeek) wrote:
try
sqlalchemy.null()
instead.Changes by Michael Bayer (@zzzeek):