forked from pganalyze/pg_query_go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
partition_elem.go
72 lines (60 loc) · 1.75 KB
/
partition_elem.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
// Auto-generated from postgres/src/include/nodes/parsenodes.h - DO NOT EDIT
package pg_query
import "encoding/json"
/*
* PartitionElem - parse-time representation of a single partition key
*
* expr can be either a raw expression tree or a parse-analyzed expression.
* We don't store these on-disk, though.
*/
type PartitionElem struct {
Name *string `json:"name"` /* name of column to partition on, or NULL */
Expr Node `json:"expr"` /* expression to partition on, or NULL */
Collation List `json:"collation"` /* name of collation; NIL = default */
Opclass List `json:"opclass"` /* name of desired opclass; NIL = default */
Location int `json:"location"` /* token location, or -1 if unknown */
}
func (node PartitionElem) MarshalJSON() ([]byte, error) {
type PartitionElemMarshalAlias PartitionElem
return json.Marshal(map[string]interface{}{
"PartitionElem": (*PartitionElemMarshalAlias)(&node),
})
}
func (node *PartitionElem) UnmarshalJSON(input []byte) (err error) {
var fields map[string]json.RawMessage
err = json.Unmarshal(input, &fields)
if err != nil {
return
}
if fields["name"] != nil {
err = json.Unmarshal(fields["name"], &node.Name)
if err != nil {
return
}
}
if fields["expr"] != nil {
node.Expr, err = UnmarshalNodeJSON(fields["expr"])
if err != nil {
return
}
}
if fields["collation"] != nil {
node.Collation.Items, err = UnmarshalNodeArrayJSON(fields["collation"])
if err != nil {
return
}
}
if fields["opclass"] != nil {
node.Opclass.Items, err = UnmarshalNodeArrayJSON(fields["opclass"])
if err != nil {
return
}
}
if fields["location"] != nil {
err = json.Unmarshal(fields["location"], &node.Location)
if err != nil {
return
}
}
return
}