diff --git a/goblin/element.py b/goblin/element.py index 8008b47b03088cfa350aa894438d8707665ddabb..3bc10a858e0c7597a1bbf7b7f8e4a0c447a5f5d6 100644 --- a/goblin/element.py +++ b/goblin/element.py @@ -153,7 +153,8 @@ class VertexPropertyDescriptor: if obj is None: return getattr(objtype.__mapping__, self._prop_name) default = self._default - if default: + if default is not None : + default = self._data_type.validate_vertex_prop( default, self._cardinality, self._vertex_property, self._data_type) @@ -185,7 +186,7 @@ class VertexProperty(Vertex, abc.BaseProperty): @property def default(self): - self._default + return self._default @property def data_type(self): diff --git a/tests/conftest.py b/tests/conftest.py index 9dee508189eb5d96bc9018360f5598ec09f453d1..de7cfff24635e9bebad2a67a5b64d43e56f2bfa9 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -56,6 +56,7 @@ class Place(element.Vertex): historical_name = HistoricalName(properties.String, card=Cardinality.list_) important_numbers = element.VertexProperty( properties.Integer, card=Cardinality.set_) + incorporated = element.VertexProperty(properties.Boolean, default=False) class Inherited(Person): diff --git a/tests/test_properties.py b/tests/test_properties.py index e3e5c159a62345a4280358a02af9792614f84c4e..5a1ca13cf83e4481e123dcc2a597d9794a3c6a41 100644 --- a/tests/test_properties.py +++ b/tests/test_properties.py @@ -43,6 +43,8 @@ def test_property_default(knows): knows.notes = 'notable' assert knows.notes == 'notable' +def test_false_bool_default(place): + assert place.incorporated.value is False def test_validation(person): person.age = 10 diff --git a/tests/test_vertex_properties_functional.py b/tests/test_vertex_properties_functional.py index d78060c9264a6fdf1188002296820582be46108b..2193951343e6c23bdc9557e6a27947b80cf7f138 100644 --- a/tests/test_vertex_properties_functional.py +++ b/tests/test_vertex_properties_functional.py @@ -97,7 +97,7 @@ async def test_metas(app, place, remote_connection): detroit = await session.save(place) dprops = await g.V(detroit.id).properties().toList() - assert len(dprops) == 3 + assert len(dprops) == 4 trav = g.V(detroit.id).properties('historical_name').valueMap(True) dmetas = await trav.toList() assert dmetas[0]['value'] == 'Detroit'