Skip to content

Commit

Permalink
Quote column names for case sensitivity
Browse files Browse the repository at this point in the history
  • Loading branch information
dmgaldi committed Jul 18, 2024
1 parent 4814d44 commit 7f83a83
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -597,10 +597,10 @@ static String generateTabularSqlForWideRows(String appDbSchema, List<VariableWit
String withClauses = joinWithClauses(withClausesList);

//
// final select -- quote the variable names for case sensitivity of var names in DIY studies.
// final select -- quote the variable names for case sensitivity of var names in studies.
// Note that the quotes are a bit of a hack, it's possible we'd rather enforce case insensitivity at load time.
//
List<String> outputCols = getColumns(outputEntity, outputVariables, Entity::getPKColName, var -> "\"" + var.getId() + "\"");
List<String> outputCols = getColumns(outputEntity, outputVariables, Entity::getPKColName, var -> quote(var.getId()));
return withClauses + NL
+ "select " + String.join(", ", outputCols) + NL
+ "from " + wideTabularWithClauseName + NL
Expand Down Expand Up @@ -882,13 +882,20 @@ static String generateTabularOrderByClause(Entity outputEntity) {
outputEntity.getAncestorPkColNames().stream().forEach(a -> cols.add(0, a));
// add output entity last
cols.add(outputEntity.getPKColName());
return "ORDER BY " + String.join(", ", cols);
List<String> quotedCols = cols.stream()
.map(FilteredResultFactory::quote)
.collect(Collectors.toList());
return "ORDER BY " + String.join(", ", quotedCols);
}

static String generateDistributionGroupByClause(VariableWithValues outputVariable) {
return "GROUP BY " + outputVariable.getType().getTallTableColumnName();
}

private static String quote(String s) {
return "\"" + s + "\"";
}


/*
* PRUNE THE COMPLETE TREE TO JUST THE "ACTIVE" ENTITIES WE WANT FOR OUR JOINS
Expand Down

0 comments on commit 7f83a83

Please sign in to comment.