preliminary release

This commit is contained in:
Roberto Treviño Cervantes
2026-10-29 12:12:28 -06:00
parent be9b528c5f
commit f65d5f3f4d
37 changed files with 2139 additions and 228 deletions
+9 -3
View File
@@ -55,7 +55,12 @@ def dependency_rank(target_key: str) -> int:
class LinkResolver:
"""Looks up parent primary keys by natural key within the batch's session,
so parents written earlier in the same uncommitted transaction are found.
A missing parent leaves the FK null, which Core allows."""
The natural key wins over an id the source sent: a hospital table carries
the hospital's internal ids, which only match ours when the parent was
loaded with its own id. An id is kept as sent only when there is no
natural key or its parent isn't loaded; a missing parent leaves the FK
null, which Core allows."""
def __init__(self, session: Session):
self._session = session
@@ -65,12 +70,13 @@ class LinkResolver:
linked = []
for link in links_for(target_key):
value = row.get(link.via_field)
if row.get(link.fk_field) is not None or value is None:
if value is None:
continue
pk = self._lookup(link, value)
if pk is not None:
if row.get(link.fk_field) != pk:
linked.append(link.fk_field)
row[link.fk_field] = pk
linked.append(link.fk_field)
return linked
def _lookup(self, link: ForeignKeyLink, value: Any) -> Any: