Exception on Labkey SQL Parse - Can't edit query source

LabKey Support Forum (Inactive)
Exception on Labkey SQL Parse - Can't edit query source Anthony Corbett  2013-09-25 14:34
Status: Closed
 
Josh,

Thanks for the help. I manually deleted the row from query.querydef and cleared the caches. This worked!

Now I went about the task of re-creating the query and I got the same error on save. So I commenting things out to see where the parse issue was happening. I found that the UNION in sub-SELECT statement in the WHERE Clause is causing the issue, though again I can't see any of the stack trace beyond the Caused by: NPE. This worked in versions prior to 13.1, so this must be a regression? The SVN # of our 13.1 labkey instance is in the thread above.

Here is the SQL:

SELECT
 demo.ParticipantId,
 contactInfo.infant_name,
 demo.hospital_enroll_site,
 demo.ParticipantId.Cohort,
 contactInfo.medRec_num,
 hsd.admission_date,
 hsd.discharge_date,
 demo.enroll_date,
 st.date as StudyTerminationDate
 FROM Demographics demo
 LEFT JOIN "Contact Sheet" contactInfo ON contactInfo.ParticipantId = demo.ParticipantId
 LEFT JOIN "Hospital Summary Dates" hsd ON hsd.ParticipantId = demo.ParticipantId
 LEFT JOIN "Study Termination" st ON st.ParticipantId = demo.ParticipantId
 WHERE demo.ParticipantId.Cohort.Label = 'hospital'
   OR hsd.ParticipantId IN (
       SELECT pcrResults.ParticipantId
       FROM "RSV PCR Results" pcrResults
       WHERE lower(pcrResults.result) <> 'negative'
       UNION
       SELECT AncCultureResults.ParticipantId
       FROM "Ancillary Illness Culture Results" AncCultureResults
       WHERE AncCultureResults.viral_culture = 1; -- 1 = RSV
   )