Escaped string properly

This commit is contained in:
Luca Frosini 2021-04-09 23:39:42 +02:00
parent 4d3e97a922
commit c7a17e6026
1 changed files with 6 additions and 5 deletions

View File

@ -1,5 +1,6 @@
package org.gcube.accounting.analytics.persistence.postgresql; package org.gcube.accounting.analytics.persistence.postgresql;
import java.sql.SQLException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Calendar; import java.util.Calendar;
import java.util.Collection; import java.util.Collection;
@ -120,7 +121,7 @@ public class Query extends PostgreSQLQuery {
return date; return date;
} }
protected void addFilters() { protected void addFilters() throws SQLException {
if(filters!=null && filters.size()>0) { if(filters!=null && filters.size()>0) {
// The first filter if the time_bucket // The first filter if the time_bucket
stringBuffer.append(" AND "); stringBuffer.append(" AND ");
@ -138,7 +139,7 @@ public class Query extends PostgreSQLQuery {
} }
} }
protected void addOrConditions(String key, Set<String> values) { protected void addOrConditions(String key, Set<String> values) throws SQLException {
if(values!=null && values.size()>0) { if(values!=null && values.size()>0) {
// The first filter if the time_bucket // The first filter if the time_bucket
stringBuffer.append(" AND ("); stringBuffer.append(" AND (");
@ -158,11 +159,11 @@ public class Query extends PostgreSQLQuery {
} }
protected void addContextFilter() { protected void addContextFilter() throws SQLException {
addOrConditions(UsageRecord.SCOPE, contexts); addOrConditions(UsageRecord.SCOPE, contexts);
} }
protected void addOrConditionFilter() { protected void addOrConditionFilter() throws SQLException {
addOrConditions(orConditionKey, orConditionValues); addOrConditions(orConditionKey, orConditionValues);
} }
@ -260,7 +261,7 @@ public class Query extends PostgreSQLQuery {
stringBuffer.append("SELECT "); stringBuffer.append("SELECT ");
} }
protected void addTemporalConstraintToQuery() { protected void addTemporalConstraintToQuery() throws SQLException {
stringBuffer.append(" WHERE "); stringBuffer.append(" WHERE ");
String tableField = getTableField(AggregatedRecord.START_TIME); String tableField = getTableField(AggregatedRecord.START_TIME);
stringBuffer.append(tableField); stringBuffer.append(tableField);