Skip to content

Commit

Permalink
fixed an issue with special column names (which could come up with au…
Browse files Browse the repository at this point in the history
…tomtic column renaming by some DBMS), by always quoting them
  • Loading branch information
junyang committed Oct 11, 2011
1 parent dc8e370 commit b3d6cdb
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions src/ra/RAXNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -214,18 +214,18 @@ public String genViewDef(DB db)
String viewDef = "SELECT ";
for (int i=0; i<input1ColumnNames.size(); i++) {
if (i > 0) viewDef += ", ";
viewDef += "V1." + input1ColumnNames.get(i);
viewDef += "V1.\"" + input1ColumnNames.get(i) + "\"";
}
for (String col : moreColumnNames) {
viewDef += ", V2." + col;
viewDef += ", V2.\"" + col + "\"";
}
viewDef += " FROM " +
getChild(0).getViewName() + " AS V1, " +
getChild(1).getViewName() + " AS V2 WHERE ";
for (int i=0; i<joinColumnNames.size(); i++) {
if (i > 0) viewDef += " AND ";
viewDef += "V1." + joinColumnNames.get(i) +
"=V2." + joinColumnNames.get(i);
viewDef += "V1.\"" + joinColumnNames.get(i) +
"\"=V2.\"" + joinColumnNames.get(i) + "\"";
}
return viewDef;
}
Expand Down Expand Up @@ -291,10 +291,10 @@ public String genViewDef(DB db)
" WHERE ";
for (int i=0; i<input1Schema.getColNames().size(); i++) {
if (i>0) viewDef += " AND ";
viewDef += getChild(0).getViewName() + "." +
input1Schema.getColNames().get(i) + "=" +
getChild(1).getViewName() + "." +
input2Schema.getColNames().get(i);
viewDef += getChild(0).getViewName() + ".\"" +
input1Schema.getColNames().get(i) + "\"=" +
getChild(1).getViewName() + ".\"" +
input2Schema.getColNames().get(i) + "\"";
}
viewDef += ")";
return viewDef;
Expand Down Expand Up @@ -330,10 +330,10 @@ public String genViewDef(DB db)
" WHERE ";
for (int i=0; i<input1Schema.getColNames().size(); i++) {
if (i>0) viewDef += " AND ";
viewDef += getChild(0).getViewName() + "." +
input1Schema.getColNames().get(i) + "=" +
getChild(1).getViewName() + "." +
input2Schema.getColNames().get(i);
viewDef += getChild(0).getViewName() + ".\"" +
input1Schema.getColNames().get(i) + "\"=" +
getChild(1).getViewName() + ".\"" +
input2Schema.getColNames().get(i) + "\"";
}
viewDef += ")";
return viewDef;
Expand Down Expand Up @@ -371,8 +371,8 @@ public String genViewDef(DB db)
String viewDef = "SELECT ";
for (int i=0; i<columnNames.size(); i++) {
if (i>0) viewDef += ", ";
viewDef += inputSchema.getColNames().get(i) + " AS " +
columnNames.get(i);
viewDef += "\"" + inputSchema.getColNames().get(i) +
"\" AS " + columnNames.get(i);
}
viewDef += " FROM " + getChild(0).getViewName();
return viewDef;
Expand Down

0 comments on commit b3d6cdb

Please sign in to comment.