forked from pganalyze/pg_query_go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
null_test_expr.go
84 lines (72 loc) · 2.19 KB
/
null_test_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
// Auto-generated from postgres/src/include/nodes/primnodes.h - DO NOT EDIT
package pg_query
import "encoding/json"
/* ----------------
* NullTest
*
* NullTest represents the operation of testing a value for NULLness.
* The appropriate test is performed and returned as a boolean Datum.
*
* When argisrow is false, this simply represents a test for the null value.
*
* When argisrow is true, the input expression must yield a rowtype, and
* the node implements "row IS [NOT] NULL" per the SQL standard. This
* includes checking individual fields for NULLness when the row datum
* itself isn't NULL.
*
* NOTE: the combination of a rowtype input and argisrow==false does NOT
* correspond to the SQL notation "row IS [NOT] NULL"; instead, this case
* represents the SQL notation "row IS [NOT] DISTINCT FROM NULL".
* ----------------
*/
type NullTest struct {
Xpr Node `json:"xpr"`
Arg Node `json:"arg"` /* input expression */
Nulltesttype NullTestType `json:"nulltesttype"` /* IS NULL, IS NOT NULL */
Argisrow bool `json:"argisrow"` /* T to perform field-by-field null checks */
Location int `json:"location"` /* token location, or -1 if unknown */
}
func (node NullTest) MarshalJSON() ([]byte, error) {
type NullTestMarshalAlias NullTest
return json.Marshal(map[string]interface{}{
"NullTest": (*NullTestMarshalAlias)(&node),
})
}
func (node *NullTest) UnmarshalJSON(input []byte) (err error) {
var fields map[string]json.RawMessage
err = json.Unmarshal(input, &fields)
if err != nil {
return
}
if fields["xpr"] != nil {
node.Xpr, err = UnmarshalNodeJSON(fields["xpr"])
if err != nil {
return
}
}
if fields["arg"] != nil {
node.Arg, err = UnmarshalNodeJSON(fields["arg"])
if err != nil {
return
}
}
if fields["nulltesttype"] != nil {
err = json.Unmarshal(fields["nulltesttype"], &node.Nulltesttype)
if err != nil {
return
}
}
if fields["argisrow"] != nil {
err = json.Unmarshal(fields["argisrow"], &node.Argisrow)
if err != nil {
return
}
}
if fields["location"] != nil {
err = json.Unmarshal(fields["location"], &node.Location)
if err != nil {
return
}
}
return
}