﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	severity	resolution	keywords	cc	db_engine	os_version
2702	Accession Dataview Maintenance Site Field is Disabled	Benjamin Haag	Benjamin Haag	"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"	defect	closed	medium		Dataviews (CT)	N/A		fixed		kurt.endress@… harold.bockelman@…	N/A	N/A
