forked from pganalyze/pg_query_go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
case_test_expr.go
66 lines (55 loc) · 1.55 KB
/
case_test_expr.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
// Auto-generated from postgres/src/include/nodes/primnodes.h - DO NOT EDIT
package pg_query
import "encoding/json"
/*
* Placeholder node for the test value to be processed by a CASE expression.
* This is effectively like a Param, but can be implemented more simply
* since we need only one replacement value at a time.
*
* We also use this in nested UPDATE expressions.
* See transformAssignmentIndirection().
*/
type CaseTestExpr struct {
Xpr Node `json:"xpr"`
TypeId Oid `json:"typeId"` /* type for substituted value */
TypeMod int32 `json:"typeMod"` /* typemod for substituted value */
Collation Oid `json:"collation"` /* collation for the substituted value */
}
func (node CaseTestExpr) MarshalJSON() ([]byte, error) {
type CaseTestExprMarshalAlias CaseTestExpr
return json.Marshal(map[string]interface{}{
"CaseTestExpr": (*CaseTestExprMarshalAlias)(&node),
})
}
func (node *CaseTestExpr) UnmarshalJSON(input []byte) (err error) {
var fields map[string]json.RawMessage
err = json.Unmarshal(input, &fields)
if err != nil {
return
}
if fields["xpr"] != nil {
node.Xpr, err = UnmarshalNodeJSON(fields["xpr"])
if err != nil {
return
}
}
if fields["typeId"] != nil {
err = json.Unmarshal(fields["typeId"], &node.TypeId)
if err != nil {
return
}
}
if fields["typeMod"] != nil {
err = json.Unmarshal(fields["typeMod"], &node.TypeMod)
if err != nil {
return
}
}
if fields["collation"] != nil {
err = json.Unmarshal(fields["collation"], &node.Collation)
if err != nil {
return
}
}
return
}