Skip to content

Commit 098011c

Browse files
committed
refactor: refine comments for id_attribute and primary key filtering in _sync.py.
1 parent 6835f05 commit 098011c

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

advanced_alchemy/repository/_sync.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1560,11 +1560,11 @@ def _get_from_db(
15601560
loader_options=loader_options,
15611561
execution_options=resolved_execution_options,
15621562
)
1563-
# Use composite-key-aware filter when id_attribute is not overridden
1563+
# Default: use primary key (handles both single and composite PKs)
15641564
if id_attribute is None:
15651565
resolved_statement = resolved_statement.where(self._build_pk_filter(item_id))
15661566
else:
1567-
# Legacy path: custom id_attribute (single column lookup only)
1567+
# Custom id_attribute override: lookup by user-specified column
15681568
resolved_statement = self._filter_select_by_kwargs(resolved_statement, [(id_attribute, item_id)])
15691569
resolved_statement = self._apply_for_update_options(resolved_statement, with_for_update)
15701570
instance = (self._execute(resolved_statement, uniquify=loader_options_have_wildcard)).scalar_one_or_none()

0 commit comments

Comments
 (0)