-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathDelete.java
More file actions
120 lines (96 loc) · 2.88 KB
/
Copy pathDelete.java
File metadata and controls
120 lines (96 loc) · 2.88 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
package jaskell.sql;
import jaskell.script.Directive;
import jaskell.script.Parameter;
import java.util.ArrayList;
import java.util.List;
public class Delete implements Directive, CouldFrom {
@Override
public String script() {
return "DELETE";
}
@Override
public List<Parameter<?>> parameters() {
return new ArrayList<>();
}
public From from(String name) {
return new From(name);
}
public From from(Directive name) {
return new From(name);
}
public static class From extends Statement implements jaskell.sql.From, CouldWhere {
Directive _from;
public From(String name){
_from = new Name(name);
}
public From(Directive name){
_from = name;
}
@Override
public String script() {
return String.format("DELETE FROM %s", _from.script());
}
@Override
public List<Parameter<?>> parameters() {
return _from.parameters();
}
public Using using(String names) {
Using re = new Using(names);
re._prefix = this;
return re;
}
public Using using(String... names) {
Using re = new Using(names);
re._prefix = this;
return re;
}
public Using using(Directive... names) {
Using re = new Using(names);
re._prefix = this;
return re;
}
public Where where(Predicate predicate){
return new Where(this, predicate);
}
}
public static class Where extends jaskell.sql.Where {
Directive _prefix;
Predicate _predicate;
public Where(Directive prefix, Predicate predicate) {
super(predicate);
this._prefix = prefix;
this._predicate = predicate;
}
@Override
public Alias as(String name) {
Alias result = new Alias(name);
result._query = this;
return result;
}
@Override
public String script() {
return String.format("%s where %s", _prefix.script(), _predicate.script());
}
@Override
public List<Parameter<?>> parameters() {
List<Parameter<?>> re = _prefix.parameters();
re.addAll(_predicate.parameters());
return re;
}
public Returning returning(String names){
Returning re = new Returning(names);
re._prefix = this;
return re;
}
public Returning returning(String... names){
Returning re = new Returning(names);
re._prefix = this;
return re;
}
public Returning returning(Directive... names){
Returning re = new Returning(names);
re._prefix = this;
return re;
}
}
}