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

Distinct query results should be navigable #1464

Closed
grantfitzsimmons opened this issue May 9, 2022 · 9 comments
Closed

Distinct query results should be navigable #1464

grantfitzsimmons opened this issue May 9, 2022 · 9 comments
Assignees
Labels
1 - Request Improvements or extensions to existing behavior 2 - Queries Issues that are related to the query builder or queries in general
Milestone

Comments

@grantfitzsimmons
Copy link
Contributor

grantfitzsimmons commented May 9, 2022

Describe the bug
Since record IDs are unique, when you are looking for distinct results, record IDs are not returned, and thus you can't link out to them.

There should be some correction to this behavior in the future if possible.

@grantfitzsimmons grantfitzsimmons added 1 - Request Improvements or extensions to existing behavior pri:unknown labels May 9, 2022
@maxpatiiuk
Copy link
Member

How should this feature even work?
Should it show the first occurrence of a duplicate record and throw out the rest?
Or aggregate multiple records into one row?
Or select a random record?

@grantfitzsimmons
Copy link
Contributor Author

How should this feature even work? Should it show the first occurrence of a duplicate record and throw out the rest? Or aggregate multiple records into one row? Or select a random record?

Very good points. I was imagining the first occurrence of a duplicate record should be navigable and used for the record set. Perhaps whether it is random or not is unimportant since the use of this feature would be for summarizing information rather than a comprehensive export.

@maxpatiiuk maxpatiiuk added this to Unsorted in Query Builder via automation May 20, 2022
@benanhalt
Copy link
Contributor

IMO the back end should detect if there is a unique field in base table included in a distinct query. In that case it would include the ids to allow navigation since the unique field would cause each row to correspond to a single base table record. This would enable a work around by turning on distinct for Andy's pet peeve about the rows being duplicated due to undisplayed fields. Possibly we could make distinct be the default, because why would you ever want duplicates? Maybe there would be performance penalties. I'm not sure. From the Third Manifesto:

By definition, relations do not contain duplicate tuples. Yet SQL does permit duplicate “tuples” in its tables—another of the many reasons why SQL tables are not true relations [72]. In the Manifesto, by contrast, duplicate tuples are absolutely, categorically, and unequivocally outlawed. What we tell you three times is true.

https://www.dcs.warwick.ac.uk/~hugh/TTM/DTATRM.pdf

@grantfitzsimmons
Copy link
Contributor Author

grantfitzsimmons commented Aug 15, 2022

Assuming the same reason is involved, exporting to a CSV is not supported. This should be addressed if there is a solution to this problem. It would be great to see this in the future!

It appears possible in Specify 6.

Reported By: Corinna at CSIRO

@benanhalt
Copy link
Contributor

I don't think #1956 is related to this.

@specifysoftware
Copy link

This issue has been mentioned on Specify Community Forum. There might be relevant details there:

https://discourse.specifysoftware.org/t/queries-7-7-4-cannot-click-records-when-distinct/820/2

@maxpatiiuk
Copy link
Member

When running a distinct query, can we mimic a distinct query using "GROUP BY" instead of "SELECT DISTINCT" and include the id in the query as a CONCAT(id, ", ") (which would be parsed on the front-end into separate records)?

@CarolineDenis
Copy link
Contributor

Will be fixed in: #4607

Query Builder automation moved this from Unsorted to Shipped Mar 5, 2024
@CarolineDenis CarolineDenis reopened this Mar 5, 2024
Query Builder automation moved this from Shipped to To do Mar 5, 2024
@CarolineDenis CarolineDenis closed this as not planned Won't fix, can't repro, duplicate, stale Mar 5, 2024
Query Builder automation moved this from To do to Shipped Mar 5, 2024
@acwhite211
Copy link
Member

This issue is now moved into #4607

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1 - Request Improvements or extensions to existing behavior 2 - Queries Issues that are related to the query builder or queries in general
Projects
Status: Done
Query Builder
  
Shipped
Development

No branches or pull requests

6 participants