Skip to content

Commit 696b047

Browse files
committed
Fix writing data in a Boolean field using the Fluent API
1 parent 3a0e550 commit 696b047

File tree

4 files changed

+23
-10
lines changed

4 files changed

+23
-10
lines changed

CHANGELOG.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Features
99
Bug Fixes
1010
---------
1111
* Unable to connect to a cloud cluster using Ubuntu 20.04 (PYTHON-1238)
12+
* [GRAPH] Can't write data in a Boolean field using the Fluent API (PYTHON-1239)
1213

1314
Others
1415
------

cassandra/datastax/graph/graphson.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
DSE Graph GraphSON 2.0 GraphSON 3.0 | Python Driver
5353
------------ | -------------- | -------------- | ------------
5454
text | string | string | str
55-
boolean | g:Boolean | g:Boolean | bool
55+
boolean | | | bool
5656
bigint | g:Int64 | g:Int64 | long
5757
int | g:Int32 | g:Int32 | int
5858
double | g:Double | g:Double | float
@@ -125,7 +125,7 @@ class TextTypeIO(GraphSONTypeIO):
125125

126126

127127
class BooleanTypeIO(GraphSONTypeIO):
128-
graphson_base_type = 'Boolean'
128+
graphson_base_type = None
129129
cql_type = 'boolean'
130130

131131
@classmethod

tests/integration/advanced/graph/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,8 @@ class ClassicGraphFixtures(GraphFixtures):
418418
@staticmethod
419419
def datatypes():
420420
data = {
421+
"boolean1": ["Boolean()", True, None],
422+
"boolean2": ["Boolean()", False, None],
421423
"point1": ["Point()", Point(.5, .13), GraphSON1Deserializer.deserialize_point],
422424
"point2": ["Point()", Point(-5, .0), GraphSON1Deserializer.deserialize_point],
423425

tests/integration/advanced/graph/test_graph_datatype.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
from cassandra.graph.query import GraphProtocol
2929
from cassandra.graph.types import VertexProperty
3030

31+
from tests.util import wait_until
3132
from tests.integration.advanced.graph import BasicGraphUnitTestCase, ClassicGraphFixtures, \
3233
ClassicGraphSchema, CoreGraphSchema
3334
from tests.integration.advanced.graph import VertexLabel, GraphTestConfiguration, GraphUnitTestCase
@@ -94,22 +95,26 @@ def _test_all_datatypes(self, schema, graphson):
9495
schema.create_vertex_label(self.session, vertex_label, execution_profile=ep)
9596
vertex = list(schema.add_vertex(self.session, vertex_label, property_name, value, execution_profile=ep))[0]
9697

97-
vertex_properties = list(schema.get_vertex_properties(
98-
self.session, vertex, execution_profile=ep))
98+
def get_vertex_properties():
99+
return list(schema.get_vertex_properties(
100+
self.session, vertex, execution_profile=ep))
99101

102+
prop_returned = 1 if DSE_VERSION < Version('5.1') else 2 # include pkid >=5.1
103+
wait_until(
104+
lambda: len(get_vertex_properties()) == prop_returned, 0.2, 15)
105+
106+
vertex_properties = get_vertex_properties()
100107
if graphson == GraphProtocol.GRAPHSON_1_0:
101108
vertex_properties = [vp.as_vertex_property() for vp in vertex_properties]
102109

103-
prop_returned = 1 if DSE_VERSION < Version('5.1') else 2 # include pkid >=5.1
104-
self.assertEqual(len(vertex_properties), prop_returned)
105110
for vp in vertex_properties:
106111
if vp.label == 'pkid':
107112
continue
108113

109114
self.assertIsInstance(vp, VertexProperty)
110115
self.assertEqual(vp.label, property_name)
111116
if graphson == GraphProtocol.GRAPHSON_1_0:
112-
deserialized_value = deserializer(vp.value)
117+
deserialized_value = deserializer(vp.value) if deserializer else vp.value
113118
self.assertEqual(deserialized_value, value)
114119
else:
115120
self.assertEqual(vp.value, value)
@@ -171,10 +176,15 @@ def __test_udt(self, schema, graphson, address_class, address_with_tags_class,
171176
schema.create_vertex_label(self.session, vertex_label, execution_profile=ep)
172177

173178
vertex = list(schema.add_vertex(self.session, vertex_label, property_name, value, execution_profile=ep))[0]
174-
vertex_properties = list(schema.get_vertex_properties(
175-
self.session, vertex, execution_profile=ep))
176179

177-
self.assertEqual(len(vertex_properties), 2) # include pkid
180+
def get_vertex_properties():
181+
return list(schema.get_vertex_properties(
182+
self.session, vertex, execution_profile=ep))
183+
184+
wait_until(
185+
lambda: len(get_vertex_properties()) == 2, 0.2, 15)
186+
187+
vertex_properties = get_vertex_properties()
178188
for vp in vertex_properties:
179189
if vp.label == 'pkid':
180190
continue

0 commit comments

Comments
 (0)