Skip to content
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

Table view should support filtering via many-to-many relationships #355

Open
simonw opened this issue Jul 31, 2018 · 10 comments
Open

Table view should support filtering via many-to-many relationships #355

simonw opened this issue Jul 31, 2018 · 10 comments

Comments

@simonw
Copy link
Owner

simonw commented Jul 31, 2018

Parent: #354

@simonw
Copy link
Owner Author

simonw commented Jul 31, 2018

@simonw
Copy link
Owner Author

simonw commented May 23, 2019

So the design I have so far is:

?_m2m_linktablename__linktablecolumn=value

I'm concerned that this doesn't take tables or columns with __ in their name into account. Does that matter? Could I support this without them?

@simonw
Copy link
Owner Author

simonw commented May 23, 2019

The alternative would be to use JSON:

?_m2m={"table":"ad_targets","column":"target_id","value":"ec3ac"}

@simonw
Copy link
Owner Author

simonw commented May 23, 2019

I think I like this better. I don't think ?_m2m= is the correct name for it though.

?_through={"table":"ad_targets","column":"target_id","value":"ec3ac"} feels a little more accurate.

@simonw
Copy link
Owner Author

simonw commented May 23, 2019

This assumes that our current table has a single, unambiguous foreign key relationship with the table indicated by the ?through= parameter.

I think that's reasonable. The JSON format could be extended to allow that side of the relationship to optionally be defined there (if the foreign key relationship is missing).

@simonw
Copy link
Owner Author

simonw commented May 23, 2019

Filtering through one table already works - you need to know that table's primary key, then you do ?column_id=pk against the first table.

Filtering through a m2m table will be handled by the new ?_through= parameter.

I'm going to leave out filtering through a second levels of joins for the moment. Potentially that could be added later as some extra complicated JSON.

@simonw simonw changed the title Table view should support filtering by many-to-many relationships Table view should support filtering via many-to-many relationships May 23, 2019
@simonw simonw closed this as completed in 172da00 May 23, 2019
@simonw
Copy link
Owner Author

simonw commented May 23, 2019

@simonw
Copy link
Owner Author

simonw commented May 23, 2019

I'm re-opening because we need a UI mechanism for deselecting this:

fixtures__roadside_attractions__2_rows_where_where_roadside_attraction_characteristics_characteristic_id____1__and_fixtures__roadside_attractions__2_rows_where_w here_roadside_attraction_characteristics_characteristic_id____1_

@simonw
Copy link
Owner Author

simonw commented May 23, 2019

I think an approach similar to how ?_where= works would do the job here.

Can address this feedback from @psychemedia while I'm at it: #429 (comment)

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant