[Sqlalchemy-tickets] Issue #3830: Column(JSON, default=None) defaults to SQL NULL in 1.1 instead of
Brought to you by:
zzzeek
From: Adrian <iss...@bi...> - 2016-10-19 14:48:17
|
New issue 3830: Column(JSON, default=None) defaults to SQL NULL in 1.1 instead of JSON null https://bitbucket.org/zzzeek/sqlalchemy/issues/3830/column-json-default-none-defaults-to-sql Adrian: ```python from datetime import datetime, date from sqlalchemy import * from sqlalchemy.orm import * from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.dialects.postgresql import JSON Base = declarative_base() class Foo(Base): __tablename__ = 'foo' id = Column(Integer, primary_key=True) json = Column(JSON, nullable=False, default=None) e = create_engine('postgresql:///test', echo=True) Base.metadata.create_all(e) s = Session(e) s.add(Foo()) s.flush() ``` This fails with the NOT NULL being violated. Using `default=JSON.NULL` works but unless I misunderstand [the docs](http://docs.sqlalchemy.org/en/rel_1_1/changelog/migration_11.html#json-null-is-inserted-as-expected-with-orm-operations-regardless-of-column-default-present) I shouldn't get a SQL NULL there. |