forked from pganalyze/pg_query_go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
type_cast.go
58 lines (48 loc) · 1.22 KB
/
type_cast.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
// Auto-generated from postgres/src/include/nodes/parsenodes.h - DO NOT EDIT
package pg_query
import "encoding/json"
/*
* TypeCast - a CAST expression
*/
type TypeCast struct {
Arg Node `json:"arg"` /* the expression being casted */
TypeName *TypeName `json:"typeName"` /* the target type */
Location int `json:"location"` /* token location, or -1 if unknown */
}
func (node TypeCast) MarshalJSON() ([]byte, error) {
type TypeCastMarshalAlias TypeCast
return json.Marshal(map[string]interface{}{
"TypeCast": (*TypeCastMarshalAlias)(&node),
})
}
func (node *TypeCast) UnmarshalJSON(input []byte) (err error) {
var fields map[string]json.RawMessage
err = json.Unmarshal(input, &fields)
if err != nil {
return
}
if fields["arg"] != nil {
node.Arg, err = UnmarshalNodeJSON(fields["arg"])
if err != nil {
return
}
}
if fields["typeName"] != nil {
var nodePtr *Node
nodePtr, err = UnmarshalNodePtrJSON(fields["typeName"])
if err != nil {
return
}
if nodePtr != nil && *nodePtr != nil {
val := (*nodePtr).(TypeName)
node.TypeName = &val
}
}
if fields["location"] != nil {
err = json.Unmarshal(fields["location"], &node.Location)
if err != nil {
return
}
}
return
}