tracktolib 0.62.0__tar.gz → 0.62.1__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tracktolib
3
- Version: 0.62.0
3
+ Version: 0.62.1
4
4
  Summary: Utility library for python
5
5
  Keywords: utility
6
6
  Author-email: julien.brayere@tracktor.fr
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "tracktolib"
3
- version = "0.62.0"
3
+ version = "0.62.1"
4
4
  authors = [
5
5
  { email = "julien.brayere@tracktor.fr" }
6
6
  ]
@@ -91,7 +91,7 @@ pythonPlatform = "Linux"
91
91
 
92
92
  [tool.commitizen]
93
93
  name = "cz_conventional_commits"
94
- version = "0.62.0"
94
+ version = "0.62.1"
95
95
  tag_format = "$version"
96
96
  version_files = [
97
97
  "pyproject.toml:version"
@@ -225,10 +225,14 @@ def get_update_fields(
225
225
 
226
226
  @dataclass
227
227
  class PGUpdateQuery(PGQuery):
228
- """Value to start the arguments from:
229
- For instance, with a value of 10, the first argument will be $11
228
+ """
229
+ Postgresql UPDATE query generator
230
230
  """
231
231
 
232
+ """
233
+ Value to start the arguments from:
234
+ For instance, with a value of 10, the first argument will be $11
235
+ """
232
236
  start_from: int | None = None
233
237
  """Keys to use for the WHERE clause. Theses fields will not be updated"""
234
238
  where_keys: list[str] | None = None
@@ -239,6 +243,8 @@ class PGUpdateQuery(PGQuery):
239
243
  return_keys: bool = False
240
244
  """Values to update using merge (like {}::jsonb || {}::jsonb)"""
241
245
  merge_keys: list[str] | None = None
246
+ """If True, the query is for many items and values will be a list of tuples"""
247
+ is_many: bool = False
242
248
 
243
249
  _update_fields: str | None = field(init=False, default=None)
244
250
  _values: list | None = field(init=False, default=None)
@@ -264,7 +270,7 @@ class PGUpdateQuery(PGQuery):
264
270
  def values(self):
265
271
  if not self._values:
266
272
  raise ValueError("No values found")
267
- if len(self.items) == 1:
273
+ if len(self.items) == 1 and not self.is_many:
268
274
  return self._values
269
275
  _where_keys = self.where_keys or []
270
276
  _keys_not_where = [k for k in self.keys if k not in _where_keys]
@@ -516,7 +522,13 @@ async def update_many(
516
522
  query_callback: QueryCallback[PGUpdateQuery] | None = None,
517
523
  ):
518
524
  query = PGUpdateQuery(
519
- table=table, items=items, start_from=start_from, where_keys=keys, where=where, merge_keys=merge_keys
525
+ table=table,
526
+ items=items,
527
+ start_from=start_from,
528
+ where_keys=keys,
529
+ where=where,
530
+ merge_keys=merge_keys,
531
+ is_many=True,
520
532
  )
521
533
  if query_callback is not None:
522
534
  query_callback(query)
File without changes