Skip to content

Commit 516c682

Browse files
committed
[SQLite] Add copy constructors for SELECTs and joins
1 parent ef595d3 commit 516c682

3 files changed

Lines changed: 27 additions & 0 deletions

File tree

configs/pmd-rules.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,5 +90,6 @@
9090
<exclude name="CommentRequired" />
9191
<exclude name="CommentSize" />
9292
<exclude name="UncommentedEmptyMethodBody" />
93+
<exclude name="UncommentedEmptyConstructor" />
9394
</rule>
9495
</ruleset>

src/sqlancer/sqlite3/ast/SQLite3Expression.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,12 @@ public enum JoinType {
138138
private SQLite3Expression onClause;
139139
private JoinType type;
140140

141+
public Join(Join other) {
142+
this.table = other.table;
143+
this.onClause = other.onClause;
144+
this.type = other.type;
145+
}
146+
141147
public Join(SQLite3Table table, SQLite3Expression onClause, JoinType type) {
142148
this.table = table;
143149
this.onClause = onClause;

src/sqlancer/sqlite3/ast/SQLite3Select.java

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

3+
import java.util.ArrayList;
34
import java.util.Collections;
45
import java.util.List;
56

@@ -18,6 +19,25 @@ public class SQLite3Select extends SQLite3Expression {
1819
private List<Join> joinStatements = Collections.emptyList();
1920
private SQLite3Expression havingClause;
2021

22+
public SQLite3Select() {
23+
}
24+
25+
public SQLite3Select(SQLite3Select other) {
26+
fromOptions = other.fromOptions;
27+
fromList = new ArrayList<>(other.fromList);
28+
whereClause = other.whereClause;
29+
groupByClause = other.groupByClause;
30+
limitClause = other.limitClause;
31+
orderByClause = new ArrayList<>(other.orderByClause);
32+
offsetClause = other.offsetClause;
33+
fetchColumns = new ArrayList<>(fetchColumns);
34+
joinStatements = new ArrayList<>();
35+
for (Join j : other.joinStatements) {
36+
joinStatements.add(new Join(j));
37+
}
38+
havingClause = other.havingClause;
39+
}
40+
2141
public enum SelectType {
2242
DISTINCT, ALL;
2343
}

0 commit comments

Comments
 (0)