Skip to content

Commit

Permalink
refactor: Qualify table names in analytics table SQL [DHIS2-16705] (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
larshelge authored Nov 18, 2024
1 parent 2d25cab commit 97fb8ad
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,11 @@ public abstract class AbstractJdbcTableManager implements AnalyticsTableManager
protected Boolean spatialSupport;

protected boolean isSpatialSupport() {
if (spatialSupport == null)
if (spatialSupport == null) {
spatialSupport = databaseInfoProvider.getDatabaseInfo().isSpatialSupport();
return spatialSupport;
}

return spatialSupport && sqlBuilder.supportsGeospatialData();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ public class DefaultAnalyticsTableGenerator implements AnalyticsTableGenerator {

private final OutliersCache outliersCache;

// TODO introduce last successful timestamps per table type

@Override
public void generateAnalyticsTables(AnalyticsTableUpdateParams params0, JobProgress progress) {
Clock clock = new Clock(log).startClock();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -526,19 +526,19 @@ public void populateTable(AnalyticsTableUpdateParams params, AnalyticsTableParti
sql.append(
replaceQualify(
"""
\s left join ${trackedentityattributevalue} "${teaUid}" on "${teaUid}".trackedentityid=te.trackedentityid \
and "${teaUid}".trackedentityattributeid = ${teaId}""",
\s left join ${trackedentityattributevalue} ${teaUid} on ${teaUid}.trackedentityid=te.trackedentityid \
and ${teaUid}.trackedentityattributeid = ${teaId}""",
Map.of(
"teaUid", tea.getUid(),
"teaUid", quote(tea.getUid()),
"teaId", String.valueOf(tea.getId())))));
sql.append(
replace(
replaceQualify(
"""
\s where te.trackedentitytypeid = ${tetId} \
and te.lastupdated < '${startTime}' \
and exists (select 1 from enrollment en \
and exists (select 1 from ${enrollment} en \
where en.trackedentityid = te.trackedentityid \
and exists (select 1 from event ev \
and exists (select 1 from ${event} ev \
where ev.enrollmentid = en.enrollmentid \
and ev.status in (${statuses}) \
and ev.deleted = false)) \
Expand Down

0 comments on commit 97fb8ad

Please sign in to comment.