quillsql 2.2.2__py3-none-any.whl → 2.2.4__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 +37 -25
- {quillsql-2.2.2.dist-info → quillsql-2.2.4.dist-info}/METADATA +1 -1
- {quillsql-2.2.2.dist-info → quillsql-2.2.4.dist-info}/RECORD +5 -5
- {quillsql-2.2.2.dist-info → quillsql-2.2.4.dist-info}/WHEEL +0 -0
- {quillsql-2.2.2.dist-info → quillsql-2.2.4.dist-info}/top_level.txt +0 -0
quillsql/core.py
CHANGED
|
@@ -129,13 +129,14 @@ class Quill:
|
|
|
129
129
|
return {
|
|
130
130
|
"status": "error",
|
|
131
131
|
"error": pivot_template_response.get("error"),
|
|
132
|
-
"data": pivot_template_response.get("metadata") or {},
|
|
132
|
+
"data": (pivot_template_response.get("metadata") or {}),
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
135
|
+
pivot_metadata = pivot_template_response.get("metadata") or {}
|
|
136
|
+
template = pivot_metadata.get("template")
|
|
137
|
+
config = pivot_metadata.get("config") or {}
|
|
138
|
+
distinct_values_query = pivot_metadata.get("distinctValuesQuery")
|
|
139
|
+
row_count_query = pivot_metadata.get("rowCountQuery")
|
|
139
140
|
|
|
140
141
|
# Step 2: Run the distinct values query to get unique values
|
|
141
142
|
distinct_values = []
|
|
@@ -180,10 +181,10 @@ class Quill:
|
|
|
180
181
|
self.target_connection.database_type,
|
|
181
182
|
metadata.get("databaseType"),
|
|
182
183
|
metadata,
|
|
183
|
-
|
|
184
|
+
pivot_metadata.get("runQueryConfig"),
|
|
184
185
|
)
|
|
185
186
|
|
|
186
|
-
responseMetadata =
|
|
187
|
+
responseMetadata = pivot_metadata or {}
|
|
187
188
|
# Set rows and fields from first query result (the pivot query)
|
|
188
189
|
if final_results.get("queryResults") and len(final_results["queryResults"]) >= 1:
|
|
189
190
|
query_results = final_results["queryResults"][0]
|
|
@@ -228,7 +229,7 @@ class Quill:
|
|
|
228
229
|
return {
|
|
229
230
|
'status': 'error',
|
|
230
231
|
'error': response.get('error'),
|
|
231
|
-
'data': response.get('metadata') or {},
|
|
232
|
+
'data': (response.get('metadata') or {}),
|
|
232
233
|
}
|
|
233
234
|
|
|
234
235
|
flag_query_results = self.run_queries(
|
|
@@ -236,16 +237,23 @@ class Quill:
|
|
|
236
237
|
self.target_connection.database_type,
|
|
237
238
|
)
|
|
238
239
|
|
|
239
|
-
tenant_flags = [
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
240
|
+
tenant_flags = []
|
|
241
|
+
response_metadata = response.get('metadata') or {}
|
|
242
|
+
query_order = response_metadata.get('queryOrder') or []
|
|
243
|
+
query_results = (flag_query_results or {}).get('queryResults') or []
|
|
244
|
+
for tenant_field, query_result in zip(query_order, query_results):
|
|
245
|
+
rows = []
|
|
246
|
+
if isinstance(query_result, dict):
|
|
247
|
+
rows = query_result.get('rows') or []
|
|
248
|
+
flags = {
|
|
249
|
+
row.get('quill_flag')
|
|
250
|
+
for row in rows
|
|
251
|
+
if isinstance(row, dict) and row.get('quill_flag') is not None
|
|
243
252
|
}
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
)
|
|
248
|
-
]
|
|
253
|
+
tenant_flags.append({
|
|
254
|
+
'tenantField': tenant_field,
|
|
255
|
+
'flags': list(flags),
|
|
256
|
+
})
|
|
249
257
|
elif tenants[0] == SINGLE_TENANT and flags:
|
|
250
258
|
if flags and isinstance(flags[0], dict):
|
|
251
259
|
tenant_flags = [{'tenantField': SINGLE_TENANT, 'flags': flags}]
|
|
@@ -330,14 +338,18 @@ class Quill:
|
|
|
330
338
|
normalized_results.get("queryResults") or []
|
|
331
339
|
)
|
|
332
340
|
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
+
run_query_config = responseMetadata.get("runQueryConfig") or {}
|
|
342
|
+
array_to_map = run_query_config.get("arrayToMap")
|
|
343
|
+
if normalized_results.get("mapped_array") and array_to_map:
|
|
344
|
+
target_collection = responseMetadata.get(array_to_map.get("arrayName"))
|
|
345
|
+
if isinstance(target_collection, list):
|
|
346
|
+
for index, mapped_rows in enumerate(normalized_results["mapped_array"]):
|
|
347
|
+
if index >= len(target_collection):
|
|
348
|
+
continue
|
|
349
|
+
target_entry = target_collection[index]
|
|
350
|
+
if isinstance(target_entry, dict):
|
|
351
|
+
target_entry[array_to_map.get("field")] = mapped_rows
|
|
352
|
+
normalized_results.pop("mapped_array", None)
|
|
341
353
|
|
|
342
354
|
query_results_list = normalized_results.get("queryResults") or []
|
|
343
355
|
if len(query_results_list) == 1:
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
quillsql/__init__.py,sha256=FiuoxaNZveKXOPB0hkpfGNlpZKmSn3pRwcqm9HKYbCQ,180
|
|
2
|
-
quillsql/core.py,sha256=
|
|
2
|
+
quillsql/core.py,sha256=HMmRtQQj3bWuLTIE8YuZaj6cAwh4bSui3pFe9pA9SgQ,23261
|
|
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.
|
|
18
|
-
quillsql-2.2.
|
|
19
|
-
quillsql-2.2.
|
|
20
|
-
quillsql-2.2.
|
|
17
|
+
quillsql-2.2.4.dist-info/METADATA,sha256=wEywCChkWsaEmZezh0DCkKUXHkgGLv0RR3OzCgEEWk0,1786
|
|
18
|
+
quillsql-2.2.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
19
|
+
quillsql-2.2.4.dist-info/top_level.txt,sha256=eU2vHnVqwpYQJ3ADl1Q-DIBzbYejZRUhcMdN_4zMCz8,9
|
|
20
|
+
quillsql-2.2.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|