-
-
Notifications
You must be signed in to change notification settings - Fork 699
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
Show referring tables and rows when the referring foreign key is compound #2003
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportBase: 92.11% // Head: 92.12% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #2003 +/- ##
==========================================
+ Coverage 92.11% 92.12% +0.01%
==========================================
Files 38 38
Lines 5555 5565 +10
==========================================
+ Hits 5117 5127 +10
Misses 438 438
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
@@ -899,8 +899,11 @@ async def expand_foreign_keys(self, database, table, column, values): | |||
fk = [ | |||
foreign_key | |||
for foreign_key in foreign_keys | |||
if foreign_key["column"] == column | |||
if foreign_key["columns"][0] == column |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because we don't have a strong idea of how to display compound foreign keys in a table view, we have to do this operation in a few places.
@@ -96,8 +96,8 @@ async def test_database_page(ds_client): | |||
"incoming": [ | |||
{ | |||
"other_table": "roadside_attraction_characteristics", | |||
"column": "pk", | |||
"other_column": "characteristic_id", | |||
"columns": ["pk"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is how the API changes.
"count": 0, | ||
"link": "/fixtures/foreign_key_references?foreign_key_with_blank_label=1", | ||
"other_columns_reference": "foreign_key_with_blank_label", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is also another API change. this got introduced so we could have compound keys look good in the row template, but we could do that through a custom filter instead.
@simonw, let me know what you think about this approach! |
see this related discussion to a change in API in sqlite-utils simonw/sqlite-utils#203 (comment) |
sqlite foreign keys can be compound, but that is not as well supported by datasette as single column foreign keys.
in particular,
Both of these issues are discussed in #1099.
This PR only fixes the second one, because it's not clear what the right UX is for the first issue.
Some things that might not be desirable about this approach.
column
=>columns
andother_column
=>other_columns
(see inline comment for more discussion.