forked from pganalyze/pg_query_go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
access_priv.go
49 lines (40 loc) · 1.18 KB
/
access_priv.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
// Auto-generated from postgres/src/include/nodes/parsenodes.h - DO NOT EDIT
package pg_query
import "encoding/json"
/*
* An access privilege, with optional list of column names
* priv_name == NULL denotes ALL PRIVILEGES (only used with a column list)
* cols == NIL denotes "all columns"
* Note that simple "ALL PRIVILEGES" is represented as a NIL list, not
* an AccessPriv with both fields null.
*/
type AccessPriv struct {
PrivName *string `json:"priv_name"` /* string name of privilege */
Cols List `json:"cols"` /* list of Value strings */
}
func (node AccessPriv) MarshalJSON() ([]byte, error) {
type AccessPrivMarshalAlias AccessPriv
return json.Marshal(map[string]interface{}{
"AccessPriv": (*AccessPrivMarshalAlias)(&node),
})
}
func (node *AccessPriv) UnmarshalJSON(input []byte) (err error) {
var fields map[string]json.RawMessage
err = json.Unmarshal(input, &fields)
if err != nil {
return
}
if fields["priv_name"] != nil {
err = json.Unmarshal(fields["priv_name"], &node.PrivName)
if err != nil {
return
}
}
if fields["cols"] != nil {
node.Cols.Items, err = UnmarshalNodeArrayJSON(fields["cols"])
if err != nil {
return
}
}
return
}