- edited description
JSON column default with __init__
Issue #3865
closed
class TestTable(Base):
test_json = Column(JSON, default={"test": "test"})
test_string = Column(String, default='test')
def __init__(self, test_json=None, test_string=None):
self.test_json=test_json
self.test_string=test_string
# insert and query
session.add(TestTable())
session.commit()
tests = session.query(TestTable).all()
for t in tests:
print(t.test_json, t.test_string)
#Result
None, 'test'
Comments (6)
-
reporter -
reporter - edited description
-
reporter - marked as minor
-
repo owner - changed status to closed
test_json = Column(JSON(none_as_null=True), default={"test": "test"})
-
reporter Thank you Michael.
-
repo owner you're welcome ! :)
- Log in to comment