|
26 | 26 | import org.labkey.test.categories.Data; |
27 | 27 | import org.labkey.test.components.ChartTypeDialog; |
28 | 28 | import org.labkey.test.pages.study.DatasetDesignerPage; |
| 29 | +import org.labkey.test.params.FieldDefinition; |
29 | 30 | import org.labkey.test.util.DataRegionTable; |
| 31 | +import org.labkey.test.util.DomainUtils; |
| 32 | +import org.labkey.test.util.EscapeUtil; |
| 33 | +import org.labkey.test.util.TestDataGenerator; |
| 34 | +import org.labkey.test.util.data.TestDataUtils; |
30 | 35 |
|
31 | 36 | import java.io.File; |
32 | 37 | import java.util.Arrays; |
@@ -182,6 +187,54 @@ public void testPivotQueryChartingTextFieldMeasure() |
182 | 187 | assertTextPresent("The y-axis measure '" + MEASURE_COLUMN + "' had 1 value(s) that could not be converted to a number and are not included in the plot"); |
183 | 188 | } |
184 | 189 |
|
| 190 | + // coverage for Issue 52739 |
| 191 | + @Test |
| 192 | + public void testBadPivotQuery() |
| 193 | + { |
| 194 | + String datasetName = TestDataGenerator.randomDomainName("D2", DomainUtils.DomainKind.StudyDatasetVisit); |
| 195 | + String textFieldName = TestDataGenerator.randomFieldName("F1", ":,;'\""); |
| 196 | + FieldDefinition textField = new FieldDefinition(textFieldName, FieldDefinition.ColumnType.String); |
| 197 | + goToProjectHome(); |
| 198 | + |
| 199 | + var datasetDesigner = _studyHelper.defineDataset(datasetName, getProjectName()); |
| 200 | + datasetDesigner.getFieldsPanel().addFields(List.of(textField)); |
| 201 | + var viewDatasetPage = datasetDesigner.clickSave() |
| 202 | + .clickViewData(); |
| 203 | + TestDataUtils.TsvQuoter _tsvQuoter = new TestDataUtils.TsvQuoter(); |
| 204 | + String bulkData = """ |
| 205 | + ParticipantId date [F1] |
| 206 | + 1 7/28/2025 this |
| 207 | + 2 7/29/2025 that |
| 208 | + 3 7/30/2025 the other |
| 209 | + 4 7/31/2025 and more |
| 210 | + 5 8/1/2025 but wait |
| 211 | + 6 8/2/2025 still more |
| 212 | + """.replace("[F1]", _tsvQuoter.quoteValue(textFieldName)); |
| 213 | + var importPage = viewDatasetPage.getDataRegion().clickImportBulkData(); |
| 214 | + importPage.setText(bulkData); |
| 215 | + importPage.submit(); |
| 216 | + |
| 217 | + // configure the query |
| 218 | + String queryName = "Q1"; |
| 219 | + String queryText = """ |
| 220 | + SELECT ParticipantId, SequenceNum, MAX([F1]) AS I1Max, [F1] FROM study.[D2] |
| 221 | + GROUP BY ParticipantId, SequenceNum, [F1] |
| 222 | + PIVOT I1Max BY [F1] |
| 223 | + """.replace("[F1]", EscapeUtil.getSqlQuotedValue(textFieldName)) |
| 224 | + .replace("[D2]", EscapeUtil.getSqlQuotedValue(datasetName)); |
| 225 | + |
| 226 | + goToModule("Query"); |
| 227 | + var createQueryPage = createNewQuery("study", datasetName); |
| 228 | + createQueryPage.setName(queryName); |
| 229 | + var sourceQueryPage = createQueryPage.clickCreate(); |
| 230 | + sourceQueryPage.setSource(queryText); |
| 231 | + var executeQueryPage = sourceQueryPage.clickSaveAndFinish(); |
| 232 | + |
| 233 | + // ensure query results contain F1 contents |
| 234 | + executeQueryPage.getDataRegion(); |
| 235 | + assertTextPresent("this", "that", "the other", "and more", "but wait", "still more"); |
| 236 | + } |
| 237 | + |
185 | 238 | @Override public BrowserType bestBrowser() |
186 | 239 | { |
187 | 240 | return BrowserType.CHROME; |
|
0 commit comments