sql-athame 0.4.0a13__py3-none-any.whl → 0.4.0a14__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 +29 -5
- {sql_athame-0.4.0a13.dist-info → sql_athame-0.4.0a14.dist-info}/METADATA +1 -1
- {sql_athame-0.4.0a13.dist-info → sql_athame-0.4.0a14.dist-info}/RECORD +5 -5
- {sql_athame-0.4.0a13.dist-info → sql_athame-0.4.0a14.dist-info}/WHEEL +0 -0
- {sql_athame-0.4.0a13.dist-info → sql_athame-0.4.0a14.dist-info}/licenses/LICENSE +0 -0
sql_athame/dataclasses.py
CHANGED
@@ -46,6 +46,7 @@ class ColumnInfo:
|
|
46
46
|
serialize: Function to transform Python values before database storage
|
47
47
|
deserialize: Function to transform database values back to Python objects
|
48
48
|
insert_only: Whether this field should only be set on INSERT, not UPDATE in upsert operations
|
49
|
+
replace_ignore: Whether this field should be ignored for `replace_multiple`
|
49
50
|
|
50
51
|
Example:
|
51
52
|
>>> from dataclasses import dataclass
|
@@ -72,6 +73,7 @@ class ColumnInfo:
|
|
72
73
|
serialize: Optional[Callable[[Any], Any]] = None
|
73
74
|
deserialize: Optional[Callable[[Any], Any]] = None
|
74
75
|
insert_only: Optional[bool] = None
|
76
|
+
replace_ignore: Optional[bool] = None
|
75
77
|
|
76
78
|
def __post_init__(self, constraints: Union[str, Iterable[str], None]) -> None:
|
77
79
|
if constraints is not None:
|
@@ -98,6 +100,9 @@ class ColumnInfo:
|
|
98
100
|
serialize=b.serialize if b.serialize is not None else a.serialize,
|
99
101
|
deserialize=b.deserialize if b.deserialize is not None else a.deserialize,
|
100
102
|
insert_only=b.insert_only if b.insert_only is not None else a.insert_only,
|
103
|
+
replace_ignore=(
|
104
|
+
b.replace_ignore if b.replace_ignore is not None else a.replace_ignore
|
105
|
+
),
|
101
106
|
)
|
102
107
|
|
103
108
|
|
@@ -118,6 +123,7 @@ class ConcreteColumnInfo:
|
|
118
123
|
serialize: Optional serialization function
|
119
124
|
deserialize: Optional deserialization function
|
120
125
|
insert_only: Whether this field should only be set on INSERT, not UPDATE
|
126
|
+
replace_ignore: Whether this field should be ignored for `replace_multiple`
|
121
127
|
"""
|
122
128
|
|
123
129
|
field: Field
|
@@ -126,9 +132,10 @@ class ConcreteColumnInfo:
|
|
126
132
|
create_type: str
|
127
133
|
nullable: bool
|
128
134
|
constraints: tuple[str, ...]
|
129
|
-
serialize: Optional[Callable[[Any], Any]]
|
130
|
-
deserialize: Optional[Callable[[Any], Any]]
|
131
|
-
insert_only: bool
|
135
|
+
serialize: Optional[Callable[[Any], Any]]
|
136
|
+
deserialize: Optional[Callable[[Any], Any]]
|
137
|
+
insert_only: bool
|
138
|
+
replace_ignore: bool
|
132
139
|
|
133
140
|
@staticmethod
|
134
141
|
def from_column_info(
|
@@ -163,6 +170,7 @@ class ConcreteColumnInfo:
|
|
163
170
|
serialize=info.serialize,
|
164
171
|
deserialize=info.deserialize,
|
165
172
|
insert_only=bool(info.insert_only),
|
173
|
+
replace_ignore=bool(info.replace_ignore),
|
166
174
|
)
|
167
175
|
|
168
176
|
def create_table_string(self) -> str:
|
@@ -386,6 +394,20 @@ class ModelBase:
|
|
386
394
|
},
|
387
395
|
)
|
388
396
|
|
397
|
+
@classmethod
|
398
|
+
def replace_ignore_field_names(cls) -> set[str]:
|
399
|
+
"""Get set of field names marked as replace_ignore in ColumnInfo.
|
400
|
+
|
401
|
+
Returns:
|
402
|
+
Set of field names that should be ignored for `replace_multiple`
|
403
|
+
"""
|
404
|
+
return cls._cached(
|
405
|
+
("replace_ignore_field_names",),
|
406
|
+
lambda: {
|
407
|
+
ci.field.name for ci in cls.column_info().values() if ci.replace_ignore
|
408
|
+
},
|
409
|
+
)
|
410
|
+
|
389
411
|
@classmethod
|
390
412
|
def field_names_sql(
|
391
413
|
cls,
|
@@ -1366,7 +1388,8 @@ class ModelBase:
|
|
1366
1388
|
"""
|
1367
1389
|
# For comparison purposes, combine auto-detected insert_only fields with manual ones
|
1368
1390
|
all_insert_only = cls.insert_only_field_names() | set(insert_only)
|
1369
|
-
|
1391
|
+
default_ignore = cls.replace_ignore_field_names() - set(force_update)
|
1392
|
+
ignore = sorted(set(ignore) | default_ignore | all_insert_only)
|
1370
1393
|
equal_ignoring = cls._cached(
|
1371
1394
|
("equal_ignoring", tuple(ignore)),
|
1372
1395
|
lambda: cls._get_equal_ignoring_fn(ignore),
|
@@ -1512,7 +1535,8 @@ class ModelBase:
|
|
1512
1535
|
"""
|
1513
1536
|
# For comparison purposes, combine auto-detected insert_only fields with manual ones
|
1514
1537
|
all_insert_only = cls.insert_only_field_names() | set(insert_only)
|
1515
|
-
|
1538
|
+
default_ignore = cls.replace_ignore_field_names() - set(force_update)
|
1539
|
+
ignore = sorted(set(ignore) | default_ignore | all_insert_only)
|
1516
1540
|
differences_ignoring = cls._cached(
|
1517
1541
|
("differences_ignoring", tuple(ignore)),
|
1518
1542
|
lambda: cls._get_differences_ignoring_fn(ignore),
|
@@ -1,11 +1,11 @@
|
|
1
1
|
sql_athame/__init__.py,sha256=0GA9-xfnZ_gw7Vysx6t4iInQ2kGXos1EYwBI6Eb7auU,100
|
2
2
|
sql_athame/base.py,sha256=yybsjDG7XgpnV1BtWCLPOzlL7TbYASt-ySyZ3VFrxdA,28402
|
3
|
-
sql_athame/dataclasses.py,sha256=
|
3
|
+
sql_athame/dataclasses.py,sha256=xsL5ZqrFyhKiR42Lw9rHUOcc7huw0eIKcphnIaTO728,58921
|
4
4
|
sql_athame/escape.py,sha256=kK101xXeFitlvuG-L_hvhdpgGJCtmRTprsn1yEfZKws,758
|
5
5
|
sql_athame/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
6
6
|
sql_athame/sqlalchemy.py,sha256=aWopfPh3j71XwKmcN_VcHRNlhscI0Sckd4AiyGf8Tpw,1293
|
7
7
|
sql_athame/types.py,sha256=FQ06l9Uc-vo57UrAarvnukILdV2gN1IaYUnHJ_bNYic,475
|
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.0a14.dist-info/METADATA,sha256=F9RykePOahwQoPEOg51C7gGKC2vnvEqInnTLGx608as,12681
|
9
|
+
sql_athame-0.4.0a14.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
10
|
+
sql_athame-0.4.0a14.dist-info/licenses/LICENSE,sha256=kPtZhuBL-A3tMrge4oz5bm_Di2M8KcA-sJY7abTEfZ4,1075
|
11
|
+
sql_athame-0.4.0a14.dist-info/RECORD,,
|
File without changes
|
File without changes
|