forked from pganalyze/pg_query_go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
common_table_expr.go
118 lines (98 loc) · 3.03 KB
/
common_table_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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
// Auto-generated from postgres/src/include/nodes/parsenodes.h - DO NOT EDIT
package pg_query
import "encoding/json"
/*
* CommonTableExpr -
* representation of WITH list element
*
* We don't currently support the SEARCH or CYCLE clause.
*/
type CommonTableExpr struct {
Ctename *string `json:"ctename"` /* query name (never qualified) */
Aliascolnames List `json:"aliascolnames"` /* optional list of column names */
/* SelectStmt/InsertStmt/etc before parse analysis, Query afterwards: */
Ctequery Node `json:"ctequery"` /* the CTE's subquery */
Location int `json:"location"` /* token location, or -1 if unknown */
/* These fields are set during parse analysis: */
Cterecursive bool `json:"cterecursive"` /* is this CTE actually recursive? */
Cterefcount int `json:"cterefcount"` /* number of RTEs referencing this CTE
* (excluding internal self-references) */
Ctecolnames List `json:"ctecolnames"` /* list of output column names */
Ctecoltypes List `json:"ctecoltypes"` /* OID list of output column type OIDs */
Ctecoltypmods List `json:"ctecoltypmods"` /* integer list of output column typmods */
Ctecolcollations List `json:"ctecolcollations"` /* OID list of column collation OIDs */
}
func (node CommonTableExpr) MarshalJSON() ([]byte, error) {
type CommonTableExprMarshalAlias CommonTableExpr
return json.Marshal(map[string]interface{}{
"CommonTableExpr": (*CommonTableExprMarshalAlias)(&node),
})
}
func (node *CommonTableExpr) UnmarshalJSON(input []byte) (err error) {
var fields map[string]json.RawMessage
err = json.Unmarshal(input, &fields)
if err != nil {
return
}
if fields["ctename"] != nil {
err = json.Unmarshal(fields["ctename"], &node.Ctename)
if err != nil {
return
}
}
if fields["aliascolnames"] != nil {
node.Aliascolnames.Items, err = UnmarshalNodeArrayJSON(fields["aliascolnames"])
if err != nil {
return
}
}
if fields["ctequery"] != nil {
node.Ctequery, err = UnmarshalNodeJSON(fields["ctequery"])
if err != nil {
return
}
}
if fields["location"] != nil {
err = json.Unmarshal(fields["location"], &node.Location)
if err != nil {
return
}
}
if fields["cterecursive"] != nil {
err = json.Unmarshal(fields["cterecursive"], &node.Cterecursive)
if err != nil {
return
}
}
if fields["cterefcount"] != nil {
err = json.Unmarshal(fields["cterefcount"], &node.Cterefcount)
if err != nil {
return
}
}
if fields["ctecolnames"] != nil {
node.Ctecolnames.Items, err = UnmarshalNodeArrayJSON(fields["ctecolnames"])
if err != nil {
return
}
}
if fields["ctecoltypes"] != nil {
node.Ctecoltypes.Items, err = UnmarshalNodeArrayJSON(fields["ctecoltypes"])
if err != nil {
return
}
}
if fields["ctecoltypmods"] != nil {
node.Ctecoltypmods.Items, err = UnmarshalNodeArrayJSON(fields["ctecoltypmods"])
if err != nil {
return
}
}
if fields["ctecolcollations"] != nil {
node.Ctecolcollations.Items, err = UnmarshalNodeArrayJSON(fields["ctecolcollations"])
if err != nil {
return
}
}
return
}