tracktolib 0.59.0__tar.gz → 0.60.0__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.
- {tracktolib-0.59.0 → tracktolib-0.60.0}/PKG-INFO +1 -1
- {tracktolib-0.59.0 → tracktolib-0.60.0}/pyproject.toml +2 -2
- {tracktolib-0.59.0 → tracktolib-0.60.0}/tracktolib/pg/__init__.py +1 -0
- {tracktolib-0.59.0 → tracktolib-0.60.0}/tracktolib/pg/query.py +18 -3
- {tracktolib-0.59.0 → tracktolib-0.60.0}/tracktolib/pg_utils.py +1 -1
- {tracktolib-0.59.0 → tracktolib-0.60.0}/LICENSE +0 -0
- {tracktolib-0.59.0 → tracktolib-0.60.0}/README.md +0 -0
- {tracktolib-0.59.0 → tracktolib-0.60.0}/tracktolib/__init__.py +0 -0
- {tracktolib-0.59.0 → tracktolib-0.60.0}/tracktolib/api.py +0 -0
- {tracktolib-0.59.0 → tracktolib-0.60.0}/tracktolib/http_utils.py +0 -0
- {tracktolib-0.59.0 → tracktolib-0.60.0}/tracktolib/logs.py +0 -0
- {tracktolib-0.59.0 → tracktolib-0.60.0}/tracktolib/pg/utils.py +0 -0
- {tracktolib-0.59.0 → tracktolib-0.60.0}/tracktolib/pg_sync.py +0 -0
- {tracktolib-0.59.0 → tracktolib-0.60.0}/tracktolib/s3/__init__.py +0 -0
- {tracktolib-0.59.0 → tracktolib-0.60.0}/tracktolib/s3/minio.py +0 -0
- {tracktolib-0.59.0 → tracktolib-0.60.0}/tracktolib/s3/s3.py +0 -0
- {tracktolib-0.59.0 → tracktolib-0.60.0}/tracktolib/tests.py +0 -0
- {tracktolib-0.59.0 → tracktolib-0.60.0}/tracktolib/utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "tracktolib"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.60.0"
|
|
4
4
|
description = "Utility library for python"
|
|
5
5
|
authors = ["Julien Brayere <julien.brayere@tracktor.fr>"]
|
|
6
6
|
license = "MIT"
|
|
@@ -83,7 +83,7 @@ pythonPlatform = "Linux"
|
|
|
83
83
|
|
|
84
84
|
[tool.commitizen]
|
|
85
85
|
name = "cz_conventional_commits"
|
|
86
|
-
version = "0.
|
|
86
|
+
version = "0.60.0"
|
|
87
87
|
tag_format = "$version"
|
|
88
88
|
version_files = [
|
|
89
89
|
"pyproject.toml:version"
|
|
@@ -17,7 +17,7 @@ V = TypeVar("V")
|
|
|
17
17
|
|
|
18
18
|
def _get_insert_query(table: str, columns: Iterable[K], values: str) -> str:
|
|
19
19
|
_columns = ", ".join(columns)
|
|
20
|
-
return f"INSERT INTO {table} AS t ({_columns}) VALUES (
|
|
20
|
+
return f"INSERT INTO {table} AS t ({_columns}) VALUES ({values})"
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
def _get_returning_query(query: str, returning: Iterable[K]) -> str:
|
|
@@ -217,7 +217,7 @@ def get_update_fields(
|
|
|
217
217
|
fields.append(
|
|
218
218
|
f"{_col} = ${_counter}"
|
|
219
219
|
if k not in _merge_keys
|
|
220
|
-
else f"{_col} = COALESCE(t.{_col},
|
|
220
|
+
else f"{_col} = COALESCE(t.{_col}, JSONB_BUILD_OBJECT()) || " f"${_counter}"
|
|
221
221
|
)
|
|
222
222
|
counter += 1
|
|
223
223
|
return ",\n".join(fields), values + where_values
|
|
@@ -264,7 +264,7 @@ class PGUpdateQuery(PGQuery):
|
|
|
264
264
|
def values(self):
|
|
265
265
|
if not self._values:
|
|
266
266
|
raise ValueError("No values found")
|
|
267
|
-
return self._values
|
|
267
|
+
return self._values if len(self.items) == 1 else super().values
|
|
268
268
|
|
|
269
269
|
def _get_where_query(self) -> str:
|
|
270
270
|
if self.where:
|
|
@@ -469,3 +469,18 @@ async def update_returning(
|
|
|
469
469
|
)
|
|
470
470
|
fn = conn.fetchval if len(returning_values or []) == 1 else conn.fetchrow
|
|
471
471
|
return await fn(query.query, *args, *query.values)
|
|
472
|
+
|
|
473
|
+
|
|
474
|
+
async def update_many(
|
|
475
|
+
conn: _Connection,
|
|
476
|
+
table: str,
|
|
477
|
+
items: list[dict],
|
|
478
|
+
keys: list[str] | None = None,
|
|
479
|
+
start_from: int | None = None,
|
|
480
|
+
where: str | None = None,
|
|
481
|
+
merge_keys: list[str] | None = None,
|
|
482
|
+
):
|
|
483
|
+
query = PGUpdateQuery(
|
|
484
|
+
table=table, items=items, start_from=start_from, where_keys=keys, where=where, merge_keys=merge_keys
|
|
485
|
+
)
|
|
486
|
+
await conn.executemany(query.query, query.values)
|
|
@@ -70,7 +70,7 @@ def get_conflict_query(
|
|
|
70
70
|
fields = ", ".join(f"{x} = COALESCE(EXCLUDED.{x}, t.{x})" for x in columns if x not in _ignore_columns)
|
|
71
71
|
if merge_columns:
|
|
72
72
|
fields = fields + ", " if fields else fields
|
|
73
|
-
fields += ", ".join(f"{x} = COALESCE(t.{x},
|
|
73
|
+
fields += ", ".join(f"{x} = COALESCE(t.{x}, JSONB_BUILD_OBJECT()) || EXCLUDED.{x}" for x in merge_columns)
|
|
74
74
|
if not fields:
|
|
75
75
|
raise ValueError("No fields set")
|
|
76
76
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|