specify / specify7

Specify 7
https://www.specifysoftware.org/products/specify-7/
GNU General Public License v2.0
60 stars 36 forks source link

QB does not use correct field format when querying in related collections #5019

Open lexiclevenger opened 1 week ago

lexiclevenger commented 1 week ago

Describe the bug When querying for fields from another related collection in Specify 6, the Query Builder would use the required field format for the queried collection instead of the one you are in. In specify 7, the Query builder uses the required field format for the query you are in.

To Reproduce Use KU Fish Voucher and Tissue collections or another database with a relationship between two collections that use different field formats for catalog numbers.

  1. Go to the Query Builder
  2. Select Collection Object as the base table
  3. Add the "catalognumber" field, add the "In" operator
  4. Add the "rightside" field from "leftsiderels," add the "In" operator
  5. Hover over both fields to see that they both use the field format for the collection you are in

Screenshot 2024-06-19 131120

Expected behavior The Query Builder should require the field format for each respective collection.

Screenshots Images from Corinna P

Issue in Specify 7: image (2)

Expected query result in Specify 6:

image (3)

Please, also fill out the following information manually:

Reported by Corinna P at CSIRO via Asana

melton-jason commented 1 week ago

This is related to https://github.com/specify/specify7/issues/1886#issuecomment-1251106441 and #2903, and should be considered when addressing either.

This adds more complexity with scoping (https://github.com/specify/specify7/issues/2912#issuecomment-1406828873), because Specify needs to resolve the CollectionRelationship -> CollectionObject to the correct scope (Collection) to determine the format for the field. The scoping of a CollectionRelationship should be determined via the CollectionRelType which has a relationship for each of the associated Collections (One for the Source Collection and one for the Destination Collection).

The general approach to #2912 , if one is possible, should hopefully facilitate determining the correct scope (collection) of a CollectionObject -> leftsiderels -> rightside collectionobject.