forked from pganalyze/pg_query_go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
named_arg_expr.go
80 lines (68 loc) · 2.01 KB
/
named_arg_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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// Auto-generated from postgres/src/include/nodes/primnodes.h - DO NOT EDIT
package pg_query
import "encoding/json"
/*
* NamedArgExpr - a named argument of a function
*
* This node type can only appear in the args list of a FuncCall or FuncExpr
* node. We support pure positional call notation (no named arguments),
* named notation (all arguments are named), and mixed notation (unnamed
* arguments followed by named ones).
*
* Parse analysis sets argnumber to the positional index of the argument,
* but doesn't rearrange the argument list.
*
* The planner will convert argument lists to pure positional notation
* during expression preprocessing, so execution never sees a NamedArgExpr.
*/
type NamedArgExpr struct {
Xpr Node `json:"xpr"`
Arg Node `json:"arg"` /* the argument expression */
Name *string `json:"name"` /* the name */
Argnumber int `json:"argnumber"` /* argument's number in positional notation */
Location int `json:"location"` /* argument name location, or -1 if unknown */
}
func (node NamedArgExpr) MarshalJSON() ([]byte, error) {
type NamedArgExprMarshalAlias NamedArgExpr
return json.Marshal(map[string]interface{}{
"NamedArgExpr": (*NamedArgExprMarshalAlias)(&node),
})
}
func (node *NamedArgExpr) 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["arg"] != nil {
node.Arg, err = UnmarshalNodeJSON(fields["arg"])
if err != nil {
return
}
}
if fields["name"] != nil {
err = json.Unmarshal(fields["name"], &node.Name)
if err != nil {
return
}
}
if fields["argnumber"] != nil {
err = json.Unmarshal(fields["argnumber"], &node.Argnumber)
if err != nil {
return
}
}
if fields["location"] != nil {
err = json.Unmarshal(fields["location"], &node.Location)
if err != nil {
return
}
}
return
}