quillsql 2.2.2__py3-none-any.whl → 2.2.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
quillsql/core.py CHANGED
@@ -236,16 +236,22 @@ class Quill:
236
236
  self.target_connection.database_type,
237
237
  )
238
238
 
239
- tenant_flags = [
240
- {
241
- 'tenantField': tenant_field,
242
- 'flags': list(set(row['quill_flag'] for row in query_result['rows']))
239
+ tenant_flags = []
240
+ query_order = response.get('metadata', {}).get('queryOrder') or []
241
+ query_results = (flag_query_results or {}).get('queryResults') or []
242
+ for tenant_field, query_result in zip(query_order, query_results):
243
+ rows = []
244
+ if isinstance(query_result, dict):
245
+ rows = query_result.get('rows') or []
246
+ flags = {
247
+ row.get('quill_flag')
248
+ for row in rows
249
+ if isinstance(row, dict) and row.get('quill_flag') is not None
243
250
  }
244
- for tenant_field, query_result in zip(
245
- response['metadata']['queryOrder'],
246
- flag_query_results['queryResults']
247
- )
248
- ]
251
+ tenant_flags.append({
252
+ 'tenantField': tenant_field,
253
+ 'flags': list(flags),
254
+ })
249
255
  elif tenants[0] == SINGLE_TENANT and flags:
250
256
  if flags and isinstance(flags[0], dict):
251
257
  tenant_flags = [{'tenantField': SINGLE_TENANT, 'flags': flags}]
@@ -330,14 +336,18 @@ class Quill:
330
336
  normalized_results.get("queryResults") or []
331
337
  )
332
338
 
333
- if (
334
- normalized_results.get("mapped_array")
335
- and responseMetadata.get("runQueryConfig", {}).get("arrayToMap")
336
- ):
337
- array_to_map = responseMetadata["runQueryConfig"]["arrayToMap"]
338
- for index, mapped_rows in enumerate(normalized_results["mapped_array"]):
339
- responseMetadata[array_to_map["arrayName"]][index][array_to_map["field"]] = mapped_rows
340
- del normalized_results["mapped_array"]
339
+ run_query_config = responseMetadata.get("runQueryConfig") or {}
340
+ array_to_map = run_query_config.get("arrayToMap")
341
+ if normalized_results.get("mapped_array") and array_to_map:
342
+ target_collection = responseMetadata.get(array_to_map.get("arrayName"))
343
+ if isinstance(target_collection, list):
344
+ for index, mapped_rows in enumerate(normalized_results["mapped_array"]):
345
+ if index >= len(target_collection):
346
+ continue
347
+ target_entry = target_collection[index]
348
+ if isinstance(target_entry, dict):
349
+ target_entry[array_to_map.get("field")] = mapped_rows
350
+ normalized_results.pop("mapped_array", None)
341
351
 
342
352
  query_results_list = normalized_results.get("queryResults") or []
343
353
  if len(query_results_list) == 1:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: quillsql
3
- Version: 2.2.2
3
+ Version: 2.2.3
4
4
  Summary: Quill SDK for Python.
5
5
  Home-page: https://github.com/quill-sql/quill-python
6
6
  Author: Quill
@@ -1,5 +1,5 @@
1
1
  quillsql/__init__.py,sha256=FiuoxaNZveKXOPB0hkpfGNlpZKmSn3pRwcqm9HKYbCQ,180
2
- quillsql/core.py,sha256=TaQ-1dKyHfR8xxDup_CogPp66MvnKwFWJV00sg61jVY,22596
2
+ quillsql/core.py,sha256=gUyM_To8Gdw30KFLqFLnvXykxCFoC7NE-A61cToEdXQ,23285
3
3
  quillsql/error.py,sha256=n9VKHw4FAgg7ZEAz2YQ8L_8FdRG_1shwGngf2iWhUSM,175
4
4
  quillsql/assets/__init__.py,sha256=oXQ2ZS5XDXkXTYjADxNfGt55cIn_rqfgWL2EDqjTyoI,45
5
5
  quillsql/assets/pgtypes.py,sha256=-B_2wUaoAsdX7_HnJhUlx4ptZQ6x-cXwuST9ACgGFdE,33820
@@ -14,7 +14,7 @@ quillsql/utils/pivot_template.py,sha256=NzHO7Ux8GVAKY-DUtsOmE7TUls2q6FJG2kgJxVWq
14
14
  quillsql/utils/run_query_processes.py,sha256=FRmNvjTDLUBr7MqDKQmivdC0anwybMXUyzQbKnaZx70,698
15
15
  quillsql/utils/schema_conversion.py,sha256=TFfMibN9nOsxNRhHw5YIFl3jGTvipG81bxX4LFDulUY,314
16
16
  quillsql/utils/tenants.py,sha256=ZD2FuKz0gjBVSsThHDv1P8PU6EL8E009NWihE5hAH-Q,2022
17
- quillsql-2.2.2.dist-info/METADATA,sha256=-6MvxXsVJQFJRkorVZXkggWzoyguME6bfnoHjYUbzD4,1786
18
- quillsql-2.2.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
19
- quillsql-2.2.2.dist-info/top_level.txt,sha256=eU2vHnVqwpYQJ3ADl1Q-DIBzbYejZRUhcMdN_4zMCz8,9
20
- quillsql-2.2.2.dist-info/RECORD,,
17
+ quillsql-2.2.3.dist-info/METADATA,sha256=m_GfCogVSbSTxw0MGKq-scyOyeipyRbcoU40BHE0yq4,1786
18
+ quillsql-2.2.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
19
+ quillsql-2.2.3.dist-info/top_level.txt,sha256=eU2vHnVqwpYQJ3ADl1Q-DIBzbYejZRUhcMdN_4zMCz8,9
20
+ quillsql-2.2.3.dist-info/RECORD,,