sql-athame 0.4.0a4__py3-none-any.whl → 0.4.0a5__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.
- sql_athame/dataclasses.py +34 -11
- {sql_athame-0.4.0a4.dist-info → sql_athame-0.4.0a5.dist-info}/METADATA +1 -1
- {sql_athame-0.4.0a4.dist-info → sql_athame-0.4.0a5.dist-info}/RECORD +5 -5
- {sql_athame-0.4.0a4.dist-info → sql_athame-0.4.0a5.dist-info}/LICENSE +0 -0
- {sql_athame-0.4.0a4.dist-info → sql_athame-0.4.0a5.dist-info}/WHEEL +0 -0
sql_athame/dataclasses.py
CHANGED
@@ -458,31 +458,46 @@ class ModelBase(Mapping[str, Any]):
|
|
458
458
|
|
459
459
|
@classmethod
|
460
460
|
async def upsert_multiple_unnest(
|
461
|
-
cls: Type[T],
|
461
|
+
cls: Type[T],
|
462
|
+
connection_or_pool: Union[Connection, Pool],
|
463
|
+
rows: Iterable[T],
|
464
|
+
insert_only: FieldNamesSet = (),
|
462
465
|
) -> str:
|
463
466
|
return await connection_or_pool.execute(
|
464
|
-
*cls.upsert_sql(cls.insert_multiple_sql(rows))
|
467
|
+
*cls.upsert_sql(cls.insert_multiple_sql(rows), exclude=insert_only)
|
465
468
|
)
|
466
469
|
|
467
470
|
@classmethod
|
468
471
|
async def upsert_multiple_array_safe(
|
469
|
-
cls: Type[T],
|
472
|
+
cls: Type[T],
|
473
|
+
connection_or_pool: Union[Connection, Pool],
|
474
|
+
rows: Iterable[T],
|
475
|
+
insert_only: FieldNamesSet = (),
|
470
476
|
) -> str:
|
471
477
|
last = ""
|
472
478
|
for chunk in chunked(rows, 100):
|
473
479
|
last = await connection_or_pool.execute(
|
474
|
-
*cls.upsert_sql(
|
480
|
+
*cls.upsert_sql(
|
481
|
+
cls.insert_multiple_array_safe_sql(chunk), exclude=insert_only
|
482
|
+
)
|
475
483
|
)
|
476
484
|
return last
|
477
485
|
|
478
486
|
@classmethod
|
479
487
|
async def upsert_multiple(
|
480
|
-
cls: Type[T],
|
488
|
+
cls: Type[T],
|
489
|
+
connection_or_pool: Union[Connection, Pool],
|
490
|
+
rows: Iterable[T],
|
491
|
+
insert_only: FieldNamesSet = (),
|
481
492
|
) -> str:
|
482
493
|
if cls.array_safe_insert:
|
483
|
-
return await cls.upsert_multiple_array_safe(
|
494
|
+
return await cls.upsert_multiple_array_safe(
|
495
|
+
connection_or_pool, rows, insert_only=insert_only
|
496
|
+
)
|
484
497
|
else:
|
485
|
-
return await cls.upsert_multiple_unnest(
|
498
|
+
return await cls.upsert_multiple_unnest(
|
499
|
+
connection_or_pool, rows, insert_only=insert_only
|
500
|
+
)
|
486
501
|
|
487
502
|
@classmethod
|
488
503
|
def _get_equal_ignoring_fn(
|
@@ -505,9 +520,11 @@ class ModelBase(Mapping[str, Any]):
|
|
505
520
|
*,
|
506
521
|
where: Where,
|
507
522
|
ignore: FieldNamesSet = (),
|
523
|
+
insert_only: FieldNamesSet = (),
|
508
524
|
) -> Tuple[List[T], List[T], List[T]]:
|
525
|
+
ignore = sorted(set(ignore) | set(insert_only))
|
509
526
|
equal_ignoring = cls._cached(
|
510
|
-
("equal_ignoring", tuple(
|
527
|
+
("equal_ignoring", tuple(ignore)),
|
511
528
|
lambda: cls._get_equal_ignoring_fn(ignore),
|
512
529
|
)
|
513
530
|
pending = {row.primary_key(): row for row in map(cls.ensure_model, rows)}
|
@@ -529,7 +546,9 @@ class ModelBase(Mapping[str, Any]):
|
|
529
546
|
created = list(pending.values())
|
530
547
|
|
531
548
|
if created or updated:
|
532
|
-
await cls.upsert_multiple(
|
549
|
+
await cls.upsert_multiple(
|
550
|
+
connection, (*created, *updated), insert_only=insert_only
|
551
|
+
)
|
533
552
|
if deleted:
|
534
553
|
await cls.delete_multiple(connection, deleted)
|
535
554
|
|
@@ -561,9 +580,11 @@ class ModelBase(Mapping[str, Any]):
|
|
561
580
|
*,
|
562
581
|
where: Where,
|
563
582
|
ignore: FieldNamesSet = (),
|
583
|
+
insert_only: FieldNamesSet = (),
|
564
584
|
) -> Tuple[List[T], List[Tuple[T, T, List[str]]], List[T]]:
|
585
|
+
ignore = sorted(set(ignore) | set(insert_only))
|
565
586
|
differences_ignoring = cls._cached(
|
566
|
-
("differences_ignoring", tuple(
|
587
|
+
("differences_ignoring", tuple(ignore)),
|
567
588
|
lambda: cls._get_differences_ignoring_fn(ignore),
|
568
589
|
)
|
569
590
|
|
@@ -588,7 +609,9 @@ class ModelBase(Mapping[str, Any]):
|
|
588
609
|
|
589
610
|
if created or updated_triples:
|
590
611
|
await cls.upsert_multiple(
|
591
|
-
connection,
|
612
|
+
connection,
|
613
|
+
(*created, *(t[1] for t in updated_triples)),
|
614
|
+
insert_only=insert_only,
|
592
615
|
)
|
593
616
|
if deleted:
|
594
617
|
await cls.delete_multiple(connection, deleted)
|
@@ -1,11 +1,11 @@
|
|
1
1
|
sql_athame/__init__.py,sha256=rzUQcbzmj3qkPZpL9jI_ALTRv-e1pAV4jSCryWkutlk,130
|
2
2
|
sql_athame/base.py,sha256=fSnHQhh5ULeJ5q32RVUAvpWtF0qoY61B2gEEP59Nrpo,10350
|
3
|
-
sql_athame/dataclasses.py,sha256=
|
3
|
+
sql_athame/dataclasses.py,sha256=KTn8bUBajNXDDVxgoBF7BdFkv8gSQynfa8fyYv8WrzM,20442
|
4
4
|
sql_athame/escape.py,sha256=LXExbiYtc407yDU4vPieyY2Pq5nypsJFfBc_2-gsbUg,743
|
5
5
|
sql_athame/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
6
6
|
sql_athame/sqlalchemy.py,sha256=c-pCLE11hTh5I19rY1Vp5E7P7lAaj9i-i7ko2L8rlF4,1305
|
7
7
|
sql_athame/types.py,sha256=7P4OyY0ezRlb2UDD9lpdXiLChnhQcBvHWaG_PKy3jmE,412
|
8
|
-
sql_athame-0.4.
|
9
|
-
sql_athame-0.4.
|
10
|
-
sql_athame-0.4.
|
11
|
-
sql_athame-0.4.
|
8
|
+
sql_athame-0.4.0a5.dist-info/LICENSE,sha256=xqV29vPFqITcKifYrGPgVIBjq4fdmLSwY3gRUtDKafg,1076
|
9
|
+
sql_athame-0.4.0a5.dist-info/METADATA,sha256=-9SuyMtbLf8Dl4oHXKPRrIGRyuVcVPc2Yt5B3958zNo,12845
|
10
|
+
sql_athame-0.4.0a5.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
11
|
+
sql_athame-0.4.0a5.dist-info/RECORD,,
|
File without changes
|
File without changes
|