|
49 | 49 | FilterableRepositoryProtocol,
|
50 | 50 | LoadSpec,
|
51 | 51 | column_has_defaults,
|
| 52 | + compare_values, |
52 | 53 | get_abstract_loader_options,
|
53 | 54 | get_instrumented_attr,
|
54 | 55 | )
|
@@ -1293,7 +1294,7 @@ async def get_or_upsert(
|
1293 | 1294 | if upsert:
|
1294 | 1295 | for field_name, new_field_value in kwargs.items():
|
1295 | 1296 | field = getattr(existing, field_name, MISSING)
|
1296 |
| - if field is not MISSING and field != new_field_value: |
| 1297 | + if field is not MISSING and not compare_values(field, new_field_value): # pragma: no cover |
1297 | 1298 | setattr(existing, field_name, new_field_value)
|
1298 | 1299 | existing = await self._attach_to_session(existing, strategy="merge")
|
1299 | 1300 | await self._flush_or_commit(auto_commit=auto_commit)
|
@@ -1367,7 +1368,7 @@ async def get_and_update(
|
1367 | 1368 | updated = False
|
1368 | 1369 | for field_name, new_field_value in kwargs.items():
|
1369 | 1370 | field = getattr(existing, field_name, MISSING)
|
1370 |
| - if field is not MISSING and field != new_field_value: |
| 1371 | + if field is not MISSING and not compare_values(field, new_field_value): # pragma: no cover |
1371 | 1372 | updated = True
|
1372 | 1373 | setattr(existing, field_name, new_field_value)
|
1373 | 1374 | existing = await self._attach_to_session(existing, strategy="merge")
|
@@ -1502,7 +1503,9 @@ async def update(
|
1502 | 1503 | if new_field_value is None and column_has_defaults(column):
|
1503 | 1504 | continue
|
1504 | 1505 | existing_field_value = getattr(existing_instance, field_name, MISSING)
|
1505 |
| - if existing_field_value is not MISSING and existing_field_value != new_field_value: |
| 1506 | + if existing_field_value is not MISSING and not compare_values( |
| 1507 | + existing_field_value, new_field_value |
| 1508 | + ): |
1506 | 1509 | setattr(existing_instance, field_name, new_field_value)
|
1507 | 1510 |
|
1508 | 1511 | # Handle relationships by merging objects into session first
|
@@ -1940,7 +1943,7 @@ async def upsert(
|
1940 | 1943 | ):
|
1941 | 1944 | for field_name, new_field_value in data.to_dict(exclude={self.id_attribute}).items():
|
1942 | 1945 | field = getattr(existing, field_name, MISSING)
|
1943 |
| - if field is not MISSING and field != new_field_value: |
| 1946 | + if field is not MISSING and not compare_values(field, new_field_value): # pragma: no cover |
1944 | 1947 | setattr(existing, field_name, new_field_value)
|
1945 | 1948 | instance = await self._attach_to_session(existing, strategy="merge")
|
1946 | 1949 | await self._flush_or_commit(auto_commit=auto_commit)
|
|
0 commit comments