Skip to content

Commit 445a6e6

Browse files
committed
Flex types return None by default #10
1 parent d9aabee commit 445a6e6

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

objectbox/model/entity.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def get_value(self, object, prop: Property):
9696
elif val == prop:
9797
if prop._py_type == datetime:
9898
return datetime.fromtimestamp(0)
99-
if prop._py_type == Generic:
99+
if prop._ob_type == OBXPropertyType_Flex:
100100
return None
101101
else:
102102
return prop._py_type() # default (empty) value for the given type

tests/test_box.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,13 @@ def test_flex_dict():
233233
box = objectbox.Box(ob, TestEntityFlex)
234234
object = TestEntityFlex()
235235

236+
# Put an empty object
237+
id = box.put(object)
238+
assert id == object.id
239+
read = box.get(object.id)
240+
assert read.flex_dict == None
241+
assert read.flex_int == None
242+
236243
object.flex_dict = {"a": 1, "b": 2}
237244
object.flex_int = 25
238245
id = box.put(object)

0 commit comments

Comments
 (0)