Skip to content

Commit

Permalink
feat: add AS support when inserting
Browse files Browse the repository at this point in the history
  • Loading branch information
zhenglinli committed Aug 27, 2023
1 parent bb4ce75 commit 0124532
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/sqlancer/stonedb/gen/StoneDBTableInsertGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ private SQLQueryAdapter getQuery() {
sb.append(table.getName());
appendPartition();
appendColumnsAndValues(columns);
appendAS();
appendOnDuplicateUpdate();
addExpectedErrors();
return new SQLQueryAdapter(sb.toString(), errors);
Expand Down Expand Up @@ -84,6 +85,14 @@ private void appendColumnsAndValues(List<StoneDBColumn> columns) {
appendValues();
}

private void appendAS() {
if (!globalState.getDbmsSpecificOptions().test80Version) {
return;
}
sb.append(" AS ");
sb.append("r").append(table.getNrRows(globalState));
}

private void appendOnDuplicateUpdate() {
sb.append("on duplicate key update ");
StoneDBColumn randomColumn = table.getRandomColumn();
Expand Down

0 comments on commit 0124532

Please sign in to comment.