forked from pganalyze/pg_query_go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_role_stmt.go
59 lines (49 loc) · 1.47 KB
/
create_role_stmt.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
// Auto-generated from postgres/src/include/nodes/parsenodes.h - DO NOT EDIT
package pg_query
import "encoding/json"
/* ----------------------
* Create/Alter/Drop Role Statements
*
* Note: these node types are also used for the backwards-compatible
* Create/Alter/Drop User/Group statements. In the ALTER and DROP cases
* there's really no need to distinguish what the original spelling was,
* but for CREATE we mark the type because the defaults vary.
* ----------------------
*/
type CreateRoleStmt struct {
StmtType RoleStmtType `json:"stmt_type"` /* ROLE/USER/GROUP */
Role *string `json:"role"` /* role name */
Options List `json:"options"` /* List of DefElem nodes */
}
func (node CreateRoleStmt) MarshalJSON() ([]byte, error) {
type CreateRoleStmtMarshalAlias CreateRoleStmt
return json.Marshal(map[string]interface{}{
"CreateRoleStmt": (*CreateRoleStmtMarshalAlias)(&node),
})
}
func (node *CreateRoleStmt) UnmarshalJSON(input []byte) (err error) {
var fields map[string]json.RawMessage
err = json.Unmarshal(input, &fields)
if err != nil {
return
}
if fields["stmt_type"] != nil {
err = json.Unmarshal(fields["stmt_type"], &node.StmtType)
if err != nil {
return
}
}
if fields["role"] != nil {
err = json.Unmarshal(fields["role"], &node.Role)
if err != nil {
return
}
}
if fields["options"] != nil {
node.Options.Items, err = UnmarshalNodeArrayJSON(fields["options"])
if err != nil {
return
}
}
return
}