summaryrefslogtreecommitdiff
path: root/test/ext/test_indexable.py
diff options
context:
space:
mode:
authorJeong YunWon <jeong@youknowone.org>2016-07-03 22:23:45 +0900
committerJeong YunWon <jeong@youknowone.org>2016-07-11 02:57:51 +0900
commit21349b23dcfd0857785aa53007cc6636259d2395 (patch)
treeaee70fe2e7e81e1dca0598361834bb78c737b56c /test/ext/test_indexable.py
parent6b6bdb354252830a1a099c92cb98064337240a1a (diff)
downloadsqlalchemy-21349b23dcfd0857785aa53007cc6636259d2395.tar.gz
Add `default` parameter for `index_property`
And force to use keyword arguments for trivial parameters in index_property Change-Id: I12a178128182f77a2d06b52d7e36f59a36b45a33
Diffstat (limited to 'test/ext/test_indexable.py')
-rw-r--r--test/ext/test_indexable.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/ext/test_indexable.py b/test/ext/test_indexable.py
index 56f2e1786..b9e942e4b 100644
--- a/test/ext/test_indexable.py
+++ b/test/ext/test_indexable.py
@@ -138,6 +138,31 @@ class IndexPropertyTest(fixtures.TestBase):
j.field = 10
eq_(j.field, 10)
+ def test_get_default_value(self):
+ Base = declarative_base()
+
+ class J(Base):
+ __tablename__ = 'j'
+ id = Column(Integer, primary_key=True)
+ json = Column(JSON, default={})
+ default = index_property('json', 'field', default='default')
+ none = index_property('json', 'field', default=None)
+
+ j = J()
+ assert j.json is None
+
+ assert j.default == 'default'
+ assert j.none is None
+ j.json = {}
+ assert j.default == 'default'
+ assert j.none is None
+ j.default = None
+ assert j.default is None
+ assert j.none is None
+ j.none = 10
+ assert j.default is 10
+ assert j.none == 10
+
class IndexPropertyArrayTest(fixtures.DeclarativeMappedTest):