MCPcopy Create free account
hub / github.com/questdb/questdb / convert_and_append_parameters

Function convert_and_append_parameters

compat/src/test/python/common.py:55–140  ·  view source on GitHub ↗
(value, type, resolved_parameters)

Source from the content-addressed store, hash-verified

53
54
55def convert_and_append_parameters(value, type, resolved_parameters):
56 if type == 'int4' or type == 'int8':
57 resolved_parameters.append(int(value))
58 elif type == 'float4' or type == 'float8':
59 resolved_parameters.append(float(value))
60 elif type == 'array_float8':
61 # Handle floating point arrays like {-1, 2, 3, 4, 5.42}
62 if isinstance(value, str):
63 # Strip curly braces and split by comma
64 value = value.strip('{}')
65 # Convert each element to float, handling null values
66 float_array = []
67 for item in value.split(','):
68 item = item.strip()
69 if not item:
70 continue
71 if item.lower() == 'null':
72 float_array.append(None)
73 else:
74 float_array.append(float(item))
75 resolved_parameters.append(float_array)
76 # If already a list, ensure all elements are floats or None
77 elif isinstance(value, list):
78 float_array = []
79 for item in value:
80 if item is None:
81 float_array.append(None)
82 else:
83 float_array.append(float(item))
84 resolved_parameters.append(float_array)
85 else:
86 raise ValueError(f"Invalid array_float8 value: {value}")
87 elif type == 'array_varchar':
88 if isinstance(value, str):
89 value = value.strip('{}')
90 str_array = []
91 i = 0
92 while i < len(value):
93 c = value[i]
94 if c == ' ' or c == ',':
95 i += 1
96 continue
97 if c == '"':
98 end = value.find('"', i + 1)
99 if end == -1:
100 raise ValueError(f"Unclosed quote in array_varchar: {value}")
101 str_array.append(value[i + 1:end])
102 i = end + 1
103 else:
104 end = value.find(',', i)
105 if end == -1:
106 end = len(value)
107 item = value[i:end].strip()
108 if item.lower() == 'null':
109 str_array.append(None)
110 else:
111 str_array.append(item)
112 i = end + 1

Callers 1

resolve_parametersFunction · 0.85

Calls 3

DecimalInterface · 0.85
appendMethod · 0.65
findMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…