Exemplo n.º 1
0
	"github.com/kr/pretty"
	nodes "github.com/lfittl/pg_query_go/nodes"
	"github.com/lfittl/pg_query_go/util"
)

var aExprTests = []struct {
	jsonText     string
	expectedNode nodes.A_Expr
}{
	{
		`{"name": [{"String": {"str": "="}}], "lexpr": null, "rexpr": null}`,
		nodes.A_Expr{
			Kind: nodes.AEXPR_OP,
			Name: util.MakeListNode([]nodes.Node{
				util.MakeStrNode("="),
			}),
			Lexpr: nil,
			Rexpr: nil,
		},
	},
	{
		`{"name": [{"String": {"str": "="}}], "lexpr": {"ColumnRef": {"fields": ` +
			`[{"String": {"str": "z"}}], "location": 22}}, "rexpr": {"A_Const": {"val": ` +
			`{"Integer": {"ival": 1}}, "location": 26}}, "location": 24}`,
		nodes.A_Expr{
			Kind: nodes.AEXPR_OP,
			Name: util.MakeListNode([]nodes.Node{
				util.MakeStrNode("="),
			}),
			Lexpr: nodes.ColumnRef{
Exemplo n.º 2
0
							},
							Location: 7,
						},
					}),
					FromClause: util.MakeListNode([]nodes.Node{
						nodes.RangeVar{
							Relname:        util.MakeStrPtr("x"),
							InhOpt:         nodes.INH_DEFAULT,
							Relpersistence: 'p',
							Location:       14,
						},
					}),
					WhereClause: nodes.A_Expr{
						Kind: nodes.AEXPR_OP,
						Name: util.MakeListNode([]nodes.Node{
							util.MakeStrNode("="),
						}),
						Lexpr: nodes.ColumnRef{
							Fields: util.MakeListNode([]nodes.Node{
								util.MakeStrNode("z"),
							}),
							Location: 22,
						},
						Rexpr: nodes.A_Const{
							Val:      util.MakeIntNode(1),
							Location: 26,
						},
						Location: 24,
					},
				},
			},