Skip to content

Commit f3d3df0

Browse files
committed
#13771 - Add NULLS LAST to ORDER BY clauses in epipulse export queries
1 parent 646d860 commit f3d3df0

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

sormas-backend/src/main/java/de/symeda/sormas/backend/epipulse/strategy/IpiExportStrategy.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ private String buildPneuSerotypingDataCte() {
222222
" AND s.deleted = false " +
223223
" AND pt.testtype IN ('SEROGROUPING', 'GENOTYPING', 'WHOLE_GENOME_SEQUENCING') " +
224224
" AND pt.typingid IS NOT NULL " +
225-
" ORDER BY COALESCE(pt.testdatetime, pt.reportdate, pt.creationdate) DESC " +
225+
" ORDER BY COALESCE(pt.testdatetime, pt.reportdate, pt.creationdate) DESC NULLS LAST, pt.id DESC " +
226226
" LIMIT 1) as serotype " +
227227
" FROM filtered_cases c)";
228228
//@formatter:on
@@ -240,7 +240,7 @@ private String buildPneuPathogenDetectionMethodCte() {
240240
" WHERE s.associatedcase_id = c.id " +
241241
" AND s.deleted = false " +
242242
" AND pt.testresultverified = true " +
243-
" ORDER BY COALESCE(pt.testdatetime, pt.reportdate, pt.creationdate) DESC " +
243+
" ORDER BY COALESCE(pt.testdatetime, pt.reportdate, pt.creationdate) DESC NULLS LAST, pt.id DESC " +
244244
" LIMIT 1) as detection_method " +
245245
" FROM filtered_cases c)";
246246
//@formatter:on
@@ -341,7 +341,7 @@ private String buildPneuAstDataCte() {
341341
" LEFT JOIN pathogentest pt ON pt.sample_id = s.id " +
342342
" AND pt.testtype = 'ANTIBIOTIC_SUSCEPTIBILITY' " +
343343
" LEFT JOIN drugsusceptibility ds ON pt.drugsusceptibility_id = ds.id " +
344-
" ORDER BY c.id, COALESCE(pt.testdatetime, pt.reportdate, pt.creationdate) DESC" +
344+
" ORDER BY c.id, COALESCE(pt.testdatetime, pt.reportdate, pt.creationdate) DESC NULLS LAST, pt.id DESC" +
345345
")";
346346
//@formatter:on
347347
}

sormas-backend/src/main/java/de/symeda/sormas/backend/epipulse/strategy/MeniExportStrategy.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ private String buildMeniSerogroupCte() {
253253
" AND s.deleted = false " +
254254
" AND pt.testtype IN ('SEROGROUPING', 'SLIDE_AGGLUTINATION') " +
255255
" AND pt.typingid IS NOT NULL " +
256-
" ORDER BY COALESCE(pt.testdatetime, pt.reportdate, pt.creationdate) DESC " +
256+
" ORDER BY COALESCE(pt.testdatetime, pt.reportdate, pt.creationdate) DESC NULLS LAST, pt.id DESC " +
257257
" LIMIT 1) as serogroup " +
258258
" FROM filtered_cases c" +
259259
")";
@@ -419,7 +419,7 @@ private String buildMeniAstDataCte() {
419419
" LEFT JOIN pathogentest pt ON pt.sample_id = s.id " +
420420
" AND pt.testtype = 'ANTIBIOTIC_SUSCEPTIBILITY' " +
421421
" LEFT JOIN drugsusceptibility ds ON pt.drugsusceptibility_id = ds.id " +
422-
" ORDER BY c.id, COALESCE(pt.testdatetime, pt.reportdate, pt.creationdate) DESC" +
422+
" ORDER BY c.id, COALESCE(pt.testdatetime, pt.reportdate, pt.creationdate) DESC NULLS LAST, pt.id DESC" +
423423
")";
424424
//@formatter:on
425425
}

0 commit comments

Comments
 (0)