package expression

import (
	"testing"
)

// TestToSQL_NotInWithArrayLiteral pins the contract that `field not in [arr]`
// is supported end-to-end by the walker. expr-lang parses this as
// `UnaryNode("not", BinaryNode("in", ..., ArrayNode))`, and the walker's
// UnaryNode "not" branch (line 108) wrapping the BinaryNode "in" array
// branch (line 167-179) emits `NOT ((field IN (?, ?...)))`. Without this
// test the SOQL semi-join resolver's NOT-IN output path (which feeds
// `field not in [id1,id2]` back into ToSQL) is implicitly relied on but
// never empirically asserted — and at least one round of Codex review on
// PR #543 misread the walker code as not supporting it. Run-not-read.
func TestToSQL_NotInWithArrayLiteral(t *testing.T) {
	cases := []struct {
		name string
		expr string
	}{
		{"non-empty IN with array", `Id in ['a','b']`},
		{"non-empty NOT IN with array (the disputed shape)", `Id not in ['a','b']`},
		{"explicit !(... in ...)", `!(Id in ['a','b'])`},
	}
	for _, tc := range cases {
		t.Run(tc.name, func(t *testing.T) {
			sql, args, err := ToSQL(tc.expr)
			t.Logf("expr=%q", tc.expr)
			t.Logf("  sql=%q", sql)
			t.Logf("  args=%v", args)
			t.Logf("  err=%v", err)
			if err != nil {
				t.Errorf("ToSQL(%q) FAILED — %v", tc.expr, err)
			}
		})
	}
}
