Opened 4 years ago

Closed 4 years ago

#2702 closed defect (fixed)

Accession Dataview Maintenance Site Field is Disabled

Reported by: Benjamin Haag Owned by: Benjamin Haag
Priority: medium Milestone:
Component: Dataviews (CT) Version: N/A
Severity: Keywords:
Cc: kurt.endress@…, harold.bockelman@… Database Engine: N/A
Operating System: N/A

Description

The Maintenance Site field in the Get Accession dataview is currently (incorrectly) greyed out. Based on troubleshooting, this is due to the Admin Tool's parsing of SQL queries that use column aliases in a particular way -- see excerpt from email from 12/14.

I figured out what’s going on. It seems familiar, so I think I noticed it before and then forgot about it. Here are some simplified examples:


This SQL doesn’t set the database field link on the sub-select field:


SELECT

a.accession_id,

(select c.site_id FROM cooperator c WHERE c.cooperator_id = a.owned_by) AS owner_site_id,

a.is_core

FROM

accession a


This SQL works to set the database field link:


SELECT

a.accession_id,

(select c.site_id FROM cooperator c WHERE c.cooperator_id = a.owned_by) AS site_id,

a.is_core

FROM

accession a


Apparently the AT gets confused when you alias the result of a sub-select to a name that doesn’t match a database field name. If you stick to the original database field name it works fine. So be careful what name is used to alias a sub-select. I guess the original author of the dataview thought it was clearer to call it owner_site_id, but that causes problems.


Note that the AT is fine with using aliases for fields that don’t come from sub-selects. This SQL that uses a JOIN instead of a sub-select works fine:

SELECT

a.accession_id,

c.site_id AS owner_site_id,

a.is_core

FROM

accession a

INNER JOIN cooperator c ON c.cooperator_id = a.owned_by


In order to make the get_accession SQL more robust we could switch to either the second or third form. I think I favor the third form.


Kurt

Attachments (1)

get_accession_20221214.dataviewxml​ (45.6 KB ) - added by Benjamin Haag 4 years ago.
Dataview modified by Kurt to address the problem.

Download all attachments as: .zip

Change History (5)

by Benjamin Haag, 4 years ago

Dataview modified by Kurt to address the problem.

comment:1 by Benjamin Haag, 4 years ago

Cc: harold.bockelman@… added
Status: assigned → addressed

comment:2 by Benjamin Haag, 4 years ago

Summary: Accession Dataview Maintenance SIte Field is Disabled → Accession Dataview Maintenance Site Field is Disabled

comment:3 by Kurt Admin, 4 years ago

After testing on npgsDev the modified dataview get_accession_20221214 was loaded on npgsweb for production use.

comment:4 by Benjamin Haag, 4 years ago

Resolution: → fixed
Status: addressed → closed
Note: See TracTickets for help on using tickets.