Skip to content

Commit 4db84e0

Browse files
authored
ID as strings and Parsing array items (#46)
* Update entity_file.py catches exceptions when inferring arrays back falls to treating them as strings * Update entity_file.py Treats ID types as strings * Update relation_type.py handles "ERROR - 'RelationType' object has no attribute 'start_namespace' ", when using enforce schema with out namespaces.
1 parent 516fa56 commit 4db84e0

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

redisgraph_bulk_loader/entity_file.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def typed_prop_to_binary(prop_val, prop_type):
6666
prop_val = prop_val.strip()
6767

6868
# TODO allow ID type specification
69-
if prop_type == Type.ID or prop_type == Type.LONG:
69+
if prop_type == Type.LONG:
7070
try:
7171
numeric_prop = int(prop_val)
7272
return struct.pack(format_str + "q", Type.LONG.value, numeric_prop)
@@ -75,7 +75,7 @@ def typed_prop_to_binary(prop_val, prop_type):
7575
if prop_type == Type.LONG:
7676
raise SchemaError("Could not parse '%s' as a long" % prop_val)
7777

78-
elif prop_type == Type.ID or prop_type == Type.DOUBLE:
78+
elif prop_type == Type.DOUBLE:
7979
try:
8080
numeric_prop = float(prop_val)
8181
if not math.isnan(numeric_prop) and not math.isinf(numeric_prop): # Don't accept non-finite values.
@@ -94,7 +94,7 @@ def typed_prop_to_binary(prop_val, prop_type):
9494
else:
9595
raise SchemaError("Could not parse '%s' as a boolean" % prop_val)
9696

97-
elif prop_type == Type.STRING:
97+
elif prop_type== Type.ID or prop_type == Type.STRING:
9898
# If we've reached this point, the property is a string
9999
encoded_str = str.encode(prop_val) # struct.pack requires bytes objects as arguments
100100
# Encoding len+1 adds a null terminator to the string
@@ -146,7 +146,10 @@ def inferred_prop_to_binary(prop_val):
146146

147147
# If the property string is bracket-interpolated, it is an array.
148148
if prop_val[0] == '[' and prop_val[-1] == ']':
149-
return array_prop_to_binary(format_str, prop_val)
149+
try:
150+
return array_prop_to_binary(format_str, prop_val)
151+
except:
152+
pass
150153

151154
# If we've reached this point, the property is a string.
152155
encoded_str = str.encode(prop_val) # struct.pack requires bytes objects as arguments

redisgraph_bulk_loader/relation_type.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ class RelationType(EntityFile):
1010
def __init__(self, query_buffer, infile, type_str, config):
1111
super(RelationType, self).__init__(infile, type_str, config)
1212
self.query_buffer = query_buffer
13+
self.start_namespace = None
14+
self.end_namespace = None
1315

1416
def process_schemaless_header(self, header):
1517
if self.column_count < 2:

0 commit comments

Comments
 (0)