-
Notifications
You must be signed in to change notification settings - Fork 397
Expand file tree
/
Copy pathCnosDBSelect.java
More file actions
102 lines (77 loc) · 2.44 KB
/
CnosDBSelect.java
File metadata and controls
102 lines (77 loc) · 2.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
package sqlancer.cnosdb.ast;
import java.util.Collections;
import java.util.List;
import sqlancer.Randomly;
import sqlancer.cnosdb.CnosDBSchema.CnosDBDataType;
import sqlancer.cnosdb.CnosDBSchema.CnosDBTable;
import sqlancer.common.ast.SelectBase;
public class CnosDBSelect extends SelectBase<CnosDBExpression> implements CnosDBExpression {
private SelectType selectOption = SelectType.ALL;
private List<CnosDBJoin> joinClauses = Collections.emptyList();
private CnosDBExpression distinctOnClause;
public void setSelectType(SelectType fromOptions) {
this.setSelectOption(fromOptions);
}
public SelectType getSelectOption() {
return selectOption;
}
public void setSelectOption(SelectType fromOptions) {
this.selectOption = fromOptions;
}
@Override
public CnosDBDataType getExpressionType() {
return null;
}
public List<CnosDBJoin> getJoinClauses() {
return joinClauses;
}
public void setJoinClauses(List<CnosDBJoin> joinStatements) {
this.joinClauses = joinStatements;
}
public CnosDBExpression getDistinctOnClause() {
return distinctOnClause;
}
public void setDistinctOnClause(CnosDBExpression distinctOnClause) {
if (selectOption != SelectType.DISTINCT) {
throw new IllegalArgumentException();
}
this.distinctOnClause = distinctOnClause;
}
public enum SelectType {
DISTINCT, ALL;
public static SelectType getRandom() {
return Randomly.fromOptions(values());
}
}
public static class CnosDBFromTable implements CnosDBExpression {
private final CnosDBTable t;
public CnosDBFromTable(CnosDBTable t) {
this.t = t;
}
public CnosDBTable getTable() {
return t;
}
@Override
public CnosDBDataType getExpressionType() {
return null;
}
}
public static class CnosDBSubquery implements CnosDBExpression {
private final CnosDBSelect s;
private final String name;
public CnosDBSubquery(CnosDBSelect s, String name) {
this.s = s;
this.name = name;
}
public CnosDBSelect getSelect() {
return s;
}
public String getName() {
return name;
}
@Override
public CnosDBDataType getExpressionType() {
return null;
}
}
}