10000 fix: Unpack all provided options and pass into FlightCallOptions. · InfluxCommunity/influxdb3-python@bd5b55f · GitHub
[go: up one dir, main page]

Skip to content

Commit bd5b55f

Browse files
committed
fix: Unpack all provided options and pass into FlightCallOptions.
1 parent 4abd41c commit bd5b55f

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

influxdb_client_3/__init__.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ def file_parser_options(**kwargs):
4242

4343

4444
def _deep_merge(target, source):
45+
"""
46+
Performs a deep merge of dictionaries or lists,
47+
recursively merging the contents, handling nested structures, and concatenation of lists.
48+
"""
4549
if isinstance(target, dict) and isinstance(source, dict):
4650
for key, value in source.items():
4751
if key in target and isinstance(target[key], (dict, list)) and isinstance(value, (dict, list)):
@@ -117,8 +121,10 @@ def __init__(
117121
port = query_port_overwrite
118122
self._flight_client = FlightClient(f"grpc+tls://{hostname}:{port}", **self._flight_client_options)
119123

120-
# Merge defaults with user-provided arguments
121124
def _merge_options(self, defaults, custom={}):
125+
"""
126+
Merge default option arguments with custom (user-provided) arguments.
127+
"""
122128
if len(custom) == 0:
123129
return defaults
124130
return _deep_merge(defaults, {key: value for key, value in custom.items()})
@@ -222,9 +228,7 @@ def query(self, query, language="sql", mode="all", database=None,**kwargs ):
222228
"timeout": 300
223229
}
224230
opts = self._merge_options(optargs, kwargs)
225-
_options = FlightCallOptions(
226-
headers=opts["headers"],
227-
timeout=opts["timeout"])
231+
_options = FlightCallOptions(**opts)
228232
ticket_data = {"database": database, "sql_query": query, "query_type": language}
229233
ticket = Ticket(json.dumps(ticket_data).encode('utf-8'))
230234
flight_reader = self._flight_client.do_get(ticket, _options)

0 commit comments

Comments
 (0)
0