-
Notifications
You must be signed in to change notification settings - Fork 97
allow setting target column for ForeignKey #395
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@theelderbeever Thanks for taking a look at it. You're right - there's a bug. The I need to write some more tests for migrations - as you say, the |
Codecov Report
@@ Coverage Diff @@
## master #395 +/- ##
==========================================
- Coverage 91.41% 91.40% -0.01%
==========================================
Files 103 103
Lines 6523 6551 +28
==========================================
+ Hits 5963 5988 +25
- Misses 560 563 +3
Continue to review full report at Codecov.
|
The file was getting too hard to understand with all of the different permutations of table.
When using a column reference instead of a string for `target_column`.
|
It seems to work now. Piccolo Admin will require some changes to support this new feature. |
|
Awesome! Would the piccolo_admin issue show up as the tables not displaying values properly by chance? |
|
@theelderbeever Yes, I think the list view and foreign key selector will be a bit broken. I'll release this, then will try and sort out the admin. |

Fixes #394
When you create a
ForeignKeywith Piccolo it automatically points to the primary key on the related table. With this PR you can specify a different column on the related table if you want (as long as it's unique).Currently a proof of concept - seems to work fine, but needs some more tests.