mirror of
https://github.com/jeffknupp/sandman2.git
synced 2026-04-25 16:45:50 +03:00
[GH-ISSUE #24] Composite primary keys #11
Labels
No labels
bug
duplicate
enhancement
help wanted
invalid
pull-request
question
refactoring
research
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/sandman2-jeffknupp#11
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @filmackay on GitHub (Jan 23, 2016).
Original GitHub issue: https://github.com/jeffknupp/sandman2/issues/24
As far as I can tell there is no support for these (multiple columns in the primary key). @jeffknupp can you outline your view on this - are they supported, to what extent, do you think they should be etc.?
@Carelvd commented on GitHub (Nov 5, 2019):
I'm not sure this is a spot on answer but I've gotten compound keys to work. If you have two tables, TABLE and FOREIGN, both of which are auto-mapped. One can subclass the latter table as follows :
I got this working after reworking the Sandman 2 code base a little, I've submitted a PR accordingly but I'm awaiting acceptance/rejection thereof. If you want to pull my variant let me know and I'll post the URL. Then one might ask if you have to map the other fields in FOREIGN and the answer is not SQLAlchemy handles this for you. If you define your own TABLE use the second variant of
__table__args__Within my own notes I have the following links 1 is mostly thoeretical, 6 discusses foreign keys, 2, 3, 4 and 7 are more convenient for resolving the problem and 5 provides a nice script for identifying compound keys.