-
Notifications
You must be signed in to change notification settings - Fork 397
Expand file tree
/
Copy pathHSQLDBJoin.java
More file actions
91 lines (71 loc) · 2.67 KB
/
HSQLDBJoin.java
File metadata and controls
91 lines (71 loc) · 2.67 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
package sqlancer.hsqldb.ast;
import sqlancer.Randomly;
import sqlancer.common.ast.newast.Join;
import sqlancer.hsqldb.HSQLDBSchema.HSQLDBColumn;
import sqlancer.hsqldb.HSQLDBSchema.HSQLDBTable;
public class HSQLDBJoin implements HSQLDBExpression, Join<HSQLDBExpression, HSQLDBTable, HSQLDBColumn> {
private final HSQLDBTableReference leftTable;
private final HSQLDBTableReference rightTable;
private final JoinType joinType;
private HSQLDBExpression onCondition;
private OuterType outerType;
public enum JoinType {
INNER, NATURAL, LEFT, RIGHT;
public static JoinType getRandom() {
return Randomly.fromOptions(values());
}
}
public enum OuterType {
FULL, LEFT, RIGHT;
public static OuterType getRandom() {
return Randomly.fromOptions(values());
}
}
public HSQLDBJoin(HSQLDBTableReference leftTable, HSQLDBTableReference rightTable, JoinType joinType,
HSQLDBExpression whereCondition) {
this.leftTable = leftTable;
this.rightTable = rightTable;
this.joinType = joinType;
this.onCondition = whereCondition;
}
public HSQLDBTableReference getLeftTable() {
return leftTable;
}
public HSQLDBTableReference getRightTable() {
return rightTable;
}
public JoinType getJoinType() {
return joinType;
}
public HSQLDBExpression getOnCondition() {
return onCondition;
}
private void setOuterType(OuterType outerType) {
this.outerType = outerType;
}
public OuterType getOuterType() {
return outerType;
}
public static HSQLDBJoin createRightOuterJoin(HSQLDBTableReference left, HSQLDBTableReference right,
HSQLDBExpression predicate) {
return new HSQLDBJoin(left, right, JoinType.RIGHT, predicate);
}
public static HSQLDBJoin createLeftOuterJoin(HSQLDBTableReference left, HSQLDBTableReference right,
HSQLDBExpression predicate) {
return new HSQLDBJoin(left, right, JoinType.LEFT, predicate);
}
public static HSQLDBJoin createInnerJoin(HSQLDBTableReference left, HSQLDBTableReference right,
HSQLDBExpression predicate) {
return new HSQLDBJoin(left, right, JoinType.INNER, predicate);
}
public static HSQLDBJoin createNaturalJoin(HSQLDBTableReference left, HSQLDBTableReference right,
OuterType naturalJoinType) {
HSQLDBJoin join = new HSQLDBJoin(left, right, JoinType.NATURAL, null);
join.setOuterType(naturalJoinType);
return join;
}
@Override
public void setOnClause(HSQLDBExpression onClause) {
onCondition = onClause;
}
}