quillsql 2.2.2__tar.gz → 2.2.3__tar.gz

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.
Files changed (26) hide show
  1. {quillsql-2.2.2 → quillsql-2.2.3}/PKG-INFO +1 -1
  2. {quillsql-2.2.2 → quillsql-2.2.3}/quillsql/core.py +27 -17
  3. {quillsql-2.2.2 → quillsql-2.2.3}/quillsql.egg-info/PKG-INFO +1 -1
  4. {quillsql-2.2.2 → quillsql-2.2.3}/quillsql.egg-info/SOURCES.txt +2 -1
  5. {quillsql-2.2.2 → quillsql-2.2.3}/setup.py +1 -1
  6. quillsql-2.2.3/tests/test_core.py +53 -0
  7. {quillsql-2.2.2 → quillsql-2.2.3}/README.md +0 -0
  8. {quillsql-2.2.2 → quillsql-2.2.3}/quillsql/__init__.py +0 -0
  9. {quillsql-2.2.2 → quillsql-2.2.3}/quillsql/assets/__init__.py +0 -0
  10. {quillsql-2.2.2 → quillsql-2.2.3}/quillsql/assets/pgtypes.py +0 -0
  11. {quillsql-2.2.2 → quillsql-2.2.3}/quillsql/db/__init__.py +0 -0
  12. {quillsql-2.2.2 → quillsql-2.2.3}/quillsql/db/bigquery.py +0 -0
  13. {quillsql-2.2.2 → quillsql-2.2.3}/quillsql/db/cached_connection.py +0 -0
  14. {quillsql-2.2.2 → quillsql-2.2.3}/quillsql/db/db_helper.py +0 -0
  15. {quillsql-2.2.2 → quillsql-2.2.3}/quillsql/db/postgres.py +0 -0
  16. {quillsql-2.2.2 → quillsql-2.2.3}/quillsql/error.py +0 -0
  17. {quillsql-2.2.2 → quillsql-2.2.3}/quillsql/utils/__init__.py +0 -0
  18. {quillsql-2.2.2 → quillsql-2.2.3}/quillsql/utils/filters.py +0 -0
  19. {quillsql-2.2.2 → quillsql-2.2.3}/quillsql/utils/pivot_template.py +0 -0
  20. {quillsql-2.2.2 → quillsql-2.2.3}/quillsql/utils/run_query_processes.py +0 -0
  21. {quillsql-2.2.2 → quillsql-2.2.3}/quillsql/utils/schema_conversion.py +0 -0
  22. {quillsql-2.2.2 → quillsql-2.2.3}/quillsql/utils/tenants.py +0 -0
  23. {quillsql-2.2.2 → quillsql-2.2.3}/quillsql.egg-info/dependency_links.txt +0 -0
  24. {quillsql-2.2.2 → quillsql-2.2.3}/quillsql.egg-info/requires.txt +0 -0
  25. {quillsql-2.2.2 → quillsql-2.2.3}/quillsql.egg-info/top_level.txt +0 -0
  26. {quillsql-2.2.2 → quillsql-2.2.3}/setup.cfg +0 -0
@@ -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
@@ -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
@@ -20,4 +20,5 @@ quillsql/utils/filters.py
20
20
  quillsql/utils/pivot_template.py
21
21
  quillsql/utils/run_query_processes.py
22
22
  quillsql/utils/schema_conversion.py
23
- quillsql/utils/tenants.py
23
+ quillsql/utils/tenants.py
24
+ tests/test_core.py
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name="quillsql",
5
- version="2.2.2",
5
+ version="2.2.3",
6
6
  packages=find_packages(),
7
7
  install_requires=[
8
8
  "psycopg2-binary",
@@ -0,0 +1,53 @@
1
+ import os
2
+ import sys
3
+ from unittest.mock import MagicMock, patch
4
+
5
+ sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
6
+
7
+ from quillsql.core import Quill
8
+
9
+
10
+ @patch("quillsql.core.CachedConnection")
11
+ def test_query_handles_none_tenant_flag_responses(mock_cached_connection):
12
+ mock_connection = MagicMock()
13
+ mock_connection.database_type = "PostgreSQL"
14
+ mock_cached_connection.return_value = mock_connection
15
+
16
+ quill = Quill(
17
+ private_key="test-key",
18
+ database_type="PostgreSQL",
19
+ database_config={},
20
+ )
21
+
22
+ quill.run_queries = MagicMock(
23
+ side_effect=[
24
+ {"queryResults": [None]},
25
+ {"queryResults": []},
26
+ ]
27
+ )
28
+
29
+ def post_quill_side_effect(path, payload):
30
+ if path == "tenant-mapped-flags":
31
+ return {
32
+ "queries": [
33
+ 'SELECT * FROM (SELECT "id" AS "customer_id", "name" AS "quill_label", "id" AS "quill_flag" FROM "public"."customers") AS "subq_owner_query" WHERE "customer_id" IN (2)'
34
+ ],
35
+ "metadata": {"queryOrder": ["customer_id"]},
36
+ }
37
+ return {"queries": [], "metadata": {}}
38
+
39
+ quill.post_quill = MagicMock(side_effect=post_quill_side_effect)
40
+
41
+ result = quill.query(
42
+ tenants=["tenant-1"],
43
+ metadata={
44
+ "task": "report",
45
+ "clientId": "client-123",
46
+ "reportId": "report-456",
47
+ "databaseType": "PostgreSQL",
48
+ },
49
+ )
50
+
51
+ assert result["status"] == "success"
52
+ assert result["data"] == {}
53
+
File without changes
File without changes
File without changes
File without changes