Skip to content

Commit

Permalink
#795 view column expressions are not escaped properly
Browse files Browse the repository at this point in the history
  • Loading branch information
ldhasson-hmhn committed Oct 5, 2023
1 parent 272f4af commit 92ebf2f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/tilda/generation/bigquery/Sql.java
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ private boolean PrintViewColumn(StringBuilder Str, ViewColumn VC, TableRankTrack
// If the column has a sameAs string, but no sameAsObj and is managed, then we print the sameAs as is.
if (VC.isSameAsLitteral() == true)
{
Str.append(TextUtil.isNullOrEmpty(VC._Expression) == true ? VC._SameAs : VC._Expression.replaceAll("\\?", VC._SameAs));
Str.append(TextUtil.isNullOrEmpty(VC._Expression) == true ? VC._SameAs : rewriteExpressionColumnQuoting(VC._Expression.replaceAll("\\?", VC._SameAs)));
}
else
{
Expand All @@ -530,7 +530,7 @@ private boolean PrintViewColumn(StringBuilder Str, ViewColumn VC, TableRankTrack
Str.append("trim(");
String ColExpr = VC._Aggregate != null && VC._Aggregate.isWindowOnly() == true ? "" : (textConversionNeeded ? "CAST(" : "") + TI.getFullName() + "." + getShortColumnVar(VC._SameAsObj.getName()) + (textConversionNeeded ? " AS STRING)" : "");
if (TextUtil.isNullOrEmpty(VC._Expression) == false)
ColExpr = VC._Expression.replaceAll("\\?", ColExpr);
ColExpr = rewriteExpressionColumnQuoting(VC._Expression.replaceAll("\\?", ColExpr));
boolean filteredAggregate = VC._Aggregate != null && TextUtil.isNullOrEmpty(VC._Filter) == false;
if (filteredAggregate == true && supportsFilterClause() == false)
Str.append("case when ").append(rewriteExpressionColumnQuoting(VC._Filter)).append(" then ");
Expand Down Expand Up @@ -1032,7 +1032,7 @@ public String genPivotColumnSQL(ViewColumn VC)

String Expr = Str.toString();
if (TextUtil.isNullOrEmpty(VC._Expression) == false)
Expr = VC._Expression.replaceAll("\\?", Expr);
Expr = rewriteExpressionColumnQuoting(VC._Expression.replaceAll("\\?", Expr));

if (TextUtil.isNullOrEmpty(VC._Coalesce) == false)
Expr = "coalesce(" + Expr + ", " + ValueHelper.printValueSQL(getSQlCodeGen(), VC.getName(), VC.getType(), VC.isCollection(), VC._Coalesce) + ")";
Expand Down
6 changes: 3 additions & 3 deletions src/tilda/generation/postgres9/Sql.java
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ private boolean PrintViewColumn(StringBuilder Str, ViewColumn VC, TableRankTrack
// If the column has a sameAs string, but no sameAsObj and is managed, then we print the sameAs as is.
if (VC.isSameAsLitteral() == true)
{
Str.append(TextUtil.isNullOrEmpty(VC._Expression) == true ? VC._SameAs : VC._Expression.replaceAll("\\?", VC._SameAs));
Str.append(TextUtil.isNullOrEmpty(VC._Expression) == true ? VC._SameAs : rewriteExpressionColumnQuoting(VC._Expression.replaceAll("\\?", VC._SameAs)));
}
else
{
Expand All @@ -697,7 +697,7 @@ private boolean PrintViewColumn(StringBuilder Str, ViewColumn VC, TableRankTrack
Str.append("trim(");
String ColExpr = VC._Aggregate != null && VC._Aggregate.isWindowOnly() == true ? "" : TI.getFullName() + ".\"" + VC._SameAsObj.getName() + "\"" + (textConversionNeeded ? "::TEXT" : "");
if (TextUtil.isNullOrEmpty(VC._Expression) == false)
ColExpr = VC._Expression.replaceAll("\\?", ColExpr);
ColExpr = rewriteExpressionColumnQuoting(VC._Expression.replaceAll("\\?", ColExpr));
Str.append(ColExpr);
if (trimNeeded)
Str.append(")");
Expand Down Expand Up @@ -1184,7 +1184,7 @@ public String genPivotColumnSQL(ViewColumn VC)

String Expr = Str.toString();
if (TextUtil.isNullOrEmpty(VC._Expression) == false)
Expr = VC._Expression.replaceAll("\\?", Expr);
Expr = rewriteExpressionColumnQuoting(VC._Expression.replaceAll("\\?", Expr));

if (TextUtil.isNullOrEmpty(VC._Coalesce) == false)
Expr = "coalesce(" + Expr + ", " + ValueHelper.printValueSQL(getSQlCodeGen(), VC.getName(), VC.getType(), VC.isCollection(), VC._Coalesce) + ")";
Expand Down

0 comments on commit 92ebf2f

Please sign in to comment.