Skip to content

Commit 0797d7a

Browse files
authored
feat(repository): add composite primary key support (#640)
Adds support for composite (multi-column) primary keys in the repository layer. Changes: - Add PrimaryKeyType type alias supporting scalar, tuple, and dict formats - Add helper methods for composite key handling: - _is_composite_pk(): Check if model has composite PK - _build_pk_filter(): Build WHERE clause for PK lookup - _extract_pk_value(): Extract PK value(s) from instance - _pk_values_present(): Check if all PK values are set - _normalize_pk_values_to_tuples(): Convert PK values to tuples for bulk ops - Update get() to support composite keys (tuple or dict input) - Update delete() to support composite keys - Update delete_many() to use tuple_().in_() for efficient bulk operations - Cache PK columns in __init__ for performance The implementation follows SQLAlchemy's native patterns and maintains full backward compatibility for single-column primary keys. Closes #189
1 parent 4001b0f commit 0797d7a

19 files changed

Lines changed: 3098 additions & 1037 deletions

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,6 @@ requirements
186186
AGENTS.md
187187
CLAUDE.md
188188
GEMINI.md
189-
189+
.agent/
190190
tools/scripts/detect_mcp_tools.py
191191
.geminiignore

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ default_language_version:
22
python: "3"
33
repos:
44
- repo: https://github.com/compilerla/conventional-pre-commit
5-
rev: v4.3.0
5+
rev: v4.4.0
66
hooks:
77
- id: conventional-pre-commit
88
stages: [commit-msg]
@@ -22,7 +22,7 @@ repos:
2222
- id: unasyncd
2323
additional_dependencies: ["ruff"]
2424
- repo: https://github.com/charliermarsh/ruff-pre-commit
25-
rev: "v0.15.0"
25+
rev: "v0.15.2"
2626
hooks:
2727
# Run the linter.
2828
- id: ruff

0 commit comments

Comments
 (0)