-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsql_delete.go
More file actions
41 lines (32 loc) · 758 Bytes
/
sql_delete.go
File metadata and controls
41 lines (32 loc) · 758 Bytes
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
package StitchingSQLGo
/*
postgres https://www.postgresql.org/docs/current/sql-delete.html
*/
type Delete struct {
Table `validate:"required"`
Where `validate:"required"`
Returning
}
func (d Delete) SQL() (string, []interface{}, error) {
if err := validate.Struct(d); err != nil {
return "", nil, err
}
s := SqlBuilder{}
s.WriteString("delete from")
if err := d.Table.Table(&s); err != nil {
return "", nil, err
}
if err := d.Where.where(&s); err != nil {
return "", nil, err
}
if err := d.Returning.Returning(&s); err != nil {
return "", nil, err
}
return s.String(), s.args, nil
}
func (d Delete) Exec() (string, []interface{}, error) {
return d.SQL()
}
func (d Delete) ExecWithReturning() Returning {
return d.Returning
}