{"html_url": "https://github.com/simonw/datasette/issues/620#issuecomment-813167335", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/620", "id": 813167335, "node_id": "MDEyOklzc3VlQ29tbWVudDgxMzE2NzMzNQ==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2021-04-05T03:57:22Z", "updated_at": "2021-04-05T03:57:22Z", "author_association": "OWNER", "body": "This may be obsoleted by #1293 - it looks like I may be able to auto-detect these foreign keys for arbitrary queries after all.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 520667773, "label": "Mechanism for indicating foreign key relationships in the table and query page URLs"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/620#issuecomment-554869243", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/620", "id": 554869243, "node_id": "MDEyOklzc3VlQ29tbWVudDU1NDg2OTI0Mw==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2019-11-18T06:16:17Z", "updated_at": "2019-11-18T06:16:51Z", "author_association": "OWNER", "body": "I think I should move the `ds.expand_foreign_keys()` method somewhere else:\r\n\r\nhttps://github.com/simonw/datasette/blob/c2779e5af0d056ef1637f9f0e191dca421259a5e/datasette/app.py#L355-L390\r\n\r\nMoving it to `Database` makes sense to me. The question we then ask it is:\r\n\r\n\"Given this column containing these values, give me back a dictionary mapping each column and value to a label - `(column, value) -> label`\"\r\n\r\nPassing in the foreign keys we have calculated as an argument makes sense.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 520667773, "label": "Mechanism for indicating foreign key relationships in the table and query page URLs"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/620#issuecomment-552252074", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/620", "id": 552252074, "node_id": "MDEyOklzc3VlQ29tbWVudDU1MjI1MjA3NA==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2019-11-11T00:28:28Z", "updated_at": "2019-11-11T00:30:53Z", "author_association": "OWNER", "body": "So for foreign key definitions it could look like this:\r\n\r\n`/db/table?_fk.article_id=articles.id`\r\n\r\nOr for columns and table names that themselves contain dots it could be:\r\n\r\n`/db/table?_fk.article_id={\"table\":\"articles\",\"column\":\"id\"}`\r\n\r\nThe value (before the =) is unambiguous -it's `?fk.XXX` where XXX could be a column name that includes periods without breaking anything.\r\n\r\nAdded bonus: if you're referencing another table's single primary key you can omit the `.id` entirely (since it can be automatically detected) - so you could do `?_fk.article_id=articles`.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 520667773, "label": "Mechanism for indicating foreign key relationships in the table and query page URLs"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/620#issuecomment-552252199", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/620", "id": 552252199, "node_id": "MDEyOklzc3VlQ29tbWVudDU1MjI1MjE5OQ==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2019-11-11T00:29:36Z", "updated_at": "2019-11-11T00:29:36Z", "author_association": "OWNER", "body": "This new `?_fk.column_name=` syntax makes me wonder if the various filters should be `?colname.contains=x` rather than `?colname__contains=x` - but that's a conversation for another time.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 520667773, "label": "Mechanism for indicating foreign key relationships in the table and query page URLs"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/620#issuecomment-552251831", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/620", "id": 552251831, "node_id": "MDEyOklzc3VlQ29tbWVudDU1MjI1MTgzMQ==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2019-11-11T00:25:58Z", "updated_at": "2019-11-11T00:25:58Z", "author_association": "OWNER", "body": "There are three pieces of information that need to be described here: the column, the other table and the other table column.\r\n\r\nWe already have a piece of API design that is similar to this: the `_through=` parameter, which looks like this:\r\n\r\n`?_through={\"table\":\"m2m_characteristics\",\"column\":\"characteristic_id\",\"value\":\"1\"}`\r\n\r\nI'm rethinking this syntax in #621 though to support a non-JSON variant that looks more like this:\r\n\r\n`?_through.roadside_attraction_characteristics.characteristic_id=1`", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 520667773, "label": "Mechanism for indicating foreign key relationships in the table and query page URLs"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/620#issuecomment-552241725", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/620", "id": 552241725, "node_id": "MDEyOklzc3VlQ29tbWVudDU1MjI0MTcyNQ==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2019-11-10T22:27:32Z", "updated_at": "2019-11-10T22:27:32Z", "author_association": "OWNER", "body": "Added bonus: this would mean faceting results could be enhanced with a \"more\" link that points to a custom paginated SQL query - but that query could maintain the ability to expand the labels on foreign keys.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 520667773, "label": "Mechanism for indicating foreign key relationships in the table and query page URLs"}, "performed_via_github_app": null}