JSON column default with __init__

Issue #3865 closed
John Kida created an issue
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)

  1. Log in to comment