Skip to content

Commit c00a19b

Browse files
committed
format the CODDTest for SQLite3 code
1 parent 0fd99d3 commit c00a19b

File tree

12 files changed

+178
-167
lines changed

12 files changed

+178
-167
lines changed

src/sqlancer/common/oracle/CODDTestBase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ public CODDTestBase(S state) {
2222
this.logger = state.getLogger();
2323
this.options = state.getOptions();
2424
}
25-
}
25+
}

src/sqlancer/common/schema/AbstractTables.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ public String columnNamesAsString(Function<C, String> function) {
3434
return getColumns().stream().map(function).collect(Collectors.joining(", "));
3535
}
3636

37-
3837
public void addTable(T table) {
3938
if (!this.tables.contains(table)) {
4039
this.tables.add(table);

src/sqlancer/sqlite3/SQLite3ExpectedValueVisitor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
import sqlancer.sqlite3.ast.SQLite3Expression.SQLite3OrderingTerm;
2323
import sqlancer.sqlite3.ast.SQLite3Expression.SQLite3PostfixText;
2424
import sqlancer.sqlite3.ast.SQLite3Expression.SQLite3PostfixUnaryOperation;
25+
import sqlancer.sqlite3.ast.SQLite3Expression.SQLite3ResultMap;
2526
import sqlancer.sqlite3.ast.SQLite3Expression.SQLite3TableAndColumnRef;
2627
import sqlancer.sqlite3.ast.SQLite3Expression.SQLite3TableReference;
27-
import sqlancer.sqlite3.ast.SQLite3Expression.SQLite3ResultMap;
2828
import sqlancer.sqlite3.ast.SQLite3Expression.SQLite3Text;
2929
import sqlancer.sqlite3.ast.SQLite3Expression.SQLite3Typeof;
3030
import sqlancer.sqlite3.ast.SQLite3Expression.SQLite3Values;
@@ -310,7 +310,7 @@ public void visit(SQLite3SetClause set) {
310310
visit(set.getRight());
311311
}
312312

313-
@Override
313+
@Override
314314
public void visit(SQLite3Alias alias) {
315315
print(alias);
316316
print(alias.getOriginalExpression());

src/sqlancer/sqlite3/SQLite3Options.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,16 +81,20 @@ public class SQLite3Options implements DBMSSpecificOptions<SQLite3OracleFactory>
8181

8282
public enum CODDTestModel {
8383
RANDOM, EXPRESSION, SUBQUERY;
84+
8485
public boolean isRandom() {
8586
return this == RANDOM;
8687
}
88+
8789
public boolean isExpression() {
8890
return this == EXPRESSION;
8991
}
92+
9093
public boolean isSubquery() {
9194
return this == SUBQUERY;
9295
}
9396
}
97+
9498
@Parameter(names = { "--coddtest-model" }, description = "Apply CODDTest on EXPRESSION, SUBQUERY, or RANDOM")
9599
public CODDTestModel coddTestModel = CODDTestModel.RANDOM;
96100

src/sqlancer/sqlite3/SQLite3ToStringVisitor.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@
2929
import sqlancer.sqlite3.ast.SQLite3Expression.SQLite3Exist;
3030
import sqlancer.sqlite3.ast.SQLite3Expression.SQLite3ExpressionBag;
3131
import sqlancer.sqlite3.ast.SQLite3Expression.SQLite3OrderingTerm;
32+
import sqlancer.sqlite3.ast.SQLite3Expression.SQLite3ResultMap;
3233
import sqlancer.sqlite3.ast.SQLite3Expression.SQLite3TableAndColumnRef;
3334
import sqlancer.sqlite3.ast.SQLite3Expression.SQLite3TableReference;
34-
import sqlancer.sqlite3.ast.SQLite3Expression.SQLite3ResultMap;
3535
import sqlancer.sqlite3.ast.SQLite3Expression.SQLite3Text;
3636
import sqlancer.sqlite3.ast.SQLite3Expression.SQLite3Typeof;
3737
import sqlancer.sqlite3.ast.SQLite3Expression.SQLite3Values;
@@ -317,7 +317,7 @@ public void visit(InOperation op) {
317317
sb.append(")");
318318
}
319319
}
320-
320+
321321
sb.append(")");
322322
}
323323

@@ -534,7 +534,7 @@ public void visit(SQLite3TableAndColumnRef tableAndColumnRef) {
534534
public void visit(SQLite3Values values) {
535535
Map<String, List<SQLite3Constant>> vs = values.getValues();
536536
int size = vs.get(vs.keySet().iterator().next()).size();
537-
List<String> columnNames = values.getColumns().stream().map(c->c.getName()).collect(Collectors.toList());
537+
List<String> columnNames = values.getColumns().stream().map(c -> c.getName()).collect(Collectors.toList());
538538
sb.append("(VALUES ");
539539
for (int i = 0; i < size; i++) {
540540
sb.append("(");
@@ -586,7 +586,7 @@ public void visit(SQLite3ResultMap tableSummary) {
586586
if (size == 0) {
587587
throw new AssertionError("The result of the expression must not be empty.");
588588
}
589-
List<String> columnNames = values.getColumns().stream().map(c->c.getName()).collect(Collectors.toList());
589+
List<String> columnNames = values.getColumns().stream().map(c -> c.getName()).collect(Collectors.toList());
590590
sb.append(" CASE ");
591591
for (int i = 0; i < size; i++) {
592592
sb.append("WHEN ");
@@ -608,4 +608,4 @@ public void visit(SQLite3ResultMap tableSummary) {
608608
}
609609
sb.append("END ");
610610
}
611-
}
611+
}

src/sqlancer/sqlite3/SQLite3Visitor.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
import sqlancer.sqlite3.ast.SQLite3Expression.SQLite3OrderingTerm;
2222
import sqlancer.sqlite3.ast.SQLite3Expression.SQLite3PostfixText;
2323
import sqlancer.sqlite3.ast.SQLite3Expression.SQLite3PostfixUnaryOperation;
24+
import sqlancer.sqlite3.ast.SQLite3Expression.SQLite3ResultMap;
2425
import sqlancer.sqlite3.ast.SQLite3Expression.SQLite3TableAndColumnRef;
2526
import sqlancer.sqlite3.ast.SQLite3Expression.SQLite3TableReference;
26-
import sqlancer.sqlite3.ast.SQLite3Expression.SQLite3ResultMap;
2727
import sqlancer.sqlite3.ast.SQLite3Expression.SQLite3Text;
2828
import sqlancer.sqlite3.ast.SQLite3Expression.SQLite3Typeof;
2929
import sqlancer.sqlite3.ast.SQLite3Expression.SQLite3Values;
@@ -137,7 +137,6 @@ default void visit(SQLite3PostfixUnaryOperation exp) {
137137

138138
void visit(SQLite3WindowFunctionFrameSpecBetween between);
139139

140-
141140
void visit(SQLite3Alias alias);
142141

143142
void visit(SQLite3WithClause withClause);

src/sqlancer/sqlite3/ast/SQLite3Expression.java

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package sqlancer.sqlite3.ast;
22

33
import java.util.List;
4-
import java.util.Optional;
54
import java.util.Map;
5+
import java.util.Optional;
66

77
import sqlancer.IgnoreMeException;
88
import sqlancer.LikeImplementationHelper;
@@ -114,7 +114,7 @@ public SQLite3CollateSequence getImplicitCollateSequence() {
114114
public static class SQLite3Exist extends SQLite3Expression {
115115

116116
private final SQLite3Expression select;
117-
private boolean negated = false;
117+
private boolean negated;
118118

119119
public SQLite3Exist(SQLite3Expression select, boolean negated) {
120120
this.select = select;
@@ -1565,7 +1565,7 @@ public boolean omitBracketsWhenPrinting() {
15651565

15661566
public static class SQLite3WithClause extends SQLite3Expression {
15671567

1568-
private SQLite3Expression left;
1568+
private final SQLite3Expression left;
15691569
private SQLite3Expression right;
15701570

15711571
public SQLite3WithClause(SQLite3Expression left, SQLite3Expression right) {
@@ -1593,23 +1593,23 @@ public SQLite3CollateSequence getExplicitCollateSequence() {
15931593

15941594
public static class SQLite3Alias extends SQLite3Expression {
15951595

1596-
private SQLite3Expression originalExpression;
1597-
private SQLite3Expression aliasExpression;
1598-
1596+
private final SQLite3Expression originalExpression;
1597+
private final SQLite3Expression aliasExpression;
1598+
15991599
public SQLite3Alias(SQLite3Expression originalExpression, SQLite3Expression aliasExpression) {
16001600
this.originalExpression = originalExpression;
16011601
this.aliasExpression = aliasExpression;
16021602
}
1603-
1603+
16041604
@Override
16051605
public SQLite3CollateSequence getExplicitCollateSequence() {
16061606
return null;
16071607
}
1608-
1608+
16091609
public SQLite3Expression getOriginalExpression() {
16101610
return originalExpression;
16111611
}
1612-
1612+
16131613
public SQLite3Expression getAliasExpression() {
16141614
return aliasExpression;
16151615
}
@@ -1673,8 +1673,7 @@ public SQLite3CollateSequence getExplicitCollateSequence() {
16731673
}
16741674
}
16751675

1676-
1677-
// The ExpressionBag is not a built-in SQL feature,
1676+
// The ExpressionBag is not a built-in SQL feature,
16781677
// but rather a utility class used in CODDTest's oracle construction
16791678
// to substitute expressions with their corresponding constant values.
16801679
public static class SQLite3ExpressionBag extends SQLite3Expression {
@@ -1700,7 +1699,7 @@ public SQLite3CollateSequence getExplicitCollateSequence() {
17001699
}
17011700

17021701
public static class SQLite3Typeof extends SQLite3Expression {
1703-
private SQLite3Expression innerExpr;
1702+
private final SQLite3Expression innerExpr;
17041703

17051704
public SQLite3Typeof(SQLite3Expression innerExpr) {
17061705
this.innerExpr = innerExpr;
@@ -1714,7 +1713,7 @@ public SQLite3Expression getInnerExpr() {
17141713
public SQLite3CollateSequence getExplicitCollateSequence() {
17151714
return null;
17161715
}
1717-
1716+
17181717
}
17191718

17201719
public static class SQLite3ResultMap extends SQLite3Expression {
@@ -1723,7 +1722,8 @@ public static class SQLite3ResultMap extends SQLite3Expression {
17231722
private final List<SQLite3Constant> summary;
17241723
private final SQLite3DataType summaryDataType;
17251724

1726-
public SQLite3ResultMap(SQLite3Values values, List<SQLite3ColumnName> columns, List<SQLite3Constant> summary, SQLite3DataType summaryDataType) {
1725+
public SQLite3ResultMap(SQLite3Values values, List<SQLite3ColumnName> columns, List<SQLite3Constant> summary,
1726+
SQLite3DataType summaryDataType) {
17271727
this.values = values;
17281728
this.columns = columns;
17291729
this.summary = summary;
@@ -1755,6 +1755,6 @@ public SQLite3DataType getSummaryDataType() {
17551755
public SQLite3CollateSequence getExplicitCollateSequence() {
17561756
return null;
17571757
}
1758-
1758+
17591759
}
1760-
}
1760+
}

src/sqlancer/sqlite3/ast/SQLite3Select.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public class SQLite3Select extends SQLite3Expression
2525
private List<SQLite3Expression> fetchColumns = Collections.emptyList();
2626
private List<Join> joinStatements = Collections.emptyList();
2727
private SQLite3Expression havingClause;
28-
private SQLite3WithClause withClause = null;
28+
private SQLite3WithClause withClause;
2929

3030
public SQLite3Select() {
3131
}
@@ -178,14 +178,14 @@ public SQLite3Expression getWithClause() {
178178
}
179179

180180
// This method is used in CODDTest to test subquery by replacing a table name
181-
// in the SELECT clause with a derived table expression.
181+
// in the SELECT clause with a derived table expression.
182182
public void replaceFromTable(String tableName, SQLite3Expression newFromExpression) {
183183
int replaceIdx = -1;
184184
for (int i = 0; i < fromList.size(); ++i) {
185185
SQLite3Expression f = fromList.get(i);
186186
if (f instanceof SQLite3TableReference) {
187187
SQLite3TableReference tableRef = (SQLite3TableReference) f;
188-
if (tableRef.getTable().getName() == tableName) {
188+
if (tableRef.getTable().getName().equals(tableName)) {
189189
replaceIdx = i;
190190
}
191191
}

0 commit comments

Comments
 (0)