forked from pganalyze/pg_query_go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update_stmt.go
88 lines (75 loc) · 2.12 KB
/
update_stmt.go
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
// Auto-generated from postgres/src/include/nodes/parsenodes.h - DO NOT EDIT
package pg_query
import "encoding/json"
/* ----------------------
* Update Statement
* ----------------------
*/
type UpdateStmt struct {
Relation *RangeVar `json:"relation"` /* relation to update */
TargetList List `json:"targetList"` /* the target list (of ResTarget) */
WhereClause Node `json:"whereClause"` /* qualifications */
FromClause List `json:"fromClause"` /* optional from clause for more tables */
ReturningList List `json:"returningList"` /* list of expressions to return */
WithClause *WithClause `json:"withClause"` /* WITH clause */
}
func (node UpdateStmt) MarshalJSON() ([]byte, error) {
type UpdateStmtMarshalAlias UpdateStmt
return json.Marshal(map[string]interface{}{
"UpdateStmt": (*UpdateStmtMarshalAlias)(&node),
})
}
func (node *UpdateStmt) UnmarshalJSON(input []byte) (err error) {
var fields map[string]json.RawMessage
err = json.Unmarshal(input, &fields)
if err != nil {
return
}
if fields["relation"] != nil {
var nodePtr *Node
nodePtr, err = UnmarshalNodePtrJSON(fields["relation"])
if err != nil {
return
}
if nodePtr != nil && *nodePtr != nil {
val := (*nodePtr).(RangeVar)
node.Relation = &val
}
}
if fields["targetList"] != nil {
node.TargetList.Items, err = UnmarshalNodeArrayJSON(fields["targetList"])
if err != nil {
return
}
}
if fields["whereClause"] != nil {
node.WhereClause, err = UnmarshalNodeJSON(fields["whereClause"])
if err != nil {
return
}
}
if fields["fromClause"] != nil {
node.FromClause.Items, err = UnmarshalNodeArrayJSON(fields["fromClause"])
if err != nil {
return
}
}
if fields["returningList"] != nil {
node.ReturningList.Items, err = UnmarshalNodeArrayJSON(fields["returningList"])
if err != nil {
return
}
}
if fields["withClause"] != nil {
var nodePtr *Node
nodePtr, err = UnmarshalNodePtrJSON(fields["withClause"])
if err != nil {
return
}
if nodePtr != nil && *nodePtr != nil {
val := (*nodePtr).(WithClause)
node.WithClause = &val
}
}
return
}