MCPcopy Index your code
hub / github.com/ent/ent / TestFieldIn

Function TestFieldIn

dialect/sql/sql_test.go:267–283  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

265}
266
267func TestFieldIn(t *testing.T) {
268 p := FieldIn("name", "a8m", "foo", "bar")
269 t.Run("MySQL", func(t *testing.T) {
270 s := Dialect(dialect.MySQL).Select("*").From(Table("users"))
271 p(s)
272 query, args := s.Query()
273 require.Equal(t, "SELECT * FROM `users` WHERE `users`.`name` IN (?, ?, ?)", query)
274 require.Equal(t, []any{"a8m", "foo", "bar"}, args)
275 })
276 t.Run("PostgreSQL", func(t *testing.T) {
277 s := Dialect(dialect.Postgres).Select("*").From(Table("users"))
278 p(s)
279 query, args := s.Query()
280 require.Equal(t, `SELECT * FROM "users" WHERE "users"."name" IN ($1, $2, $3)`, query)
281 require.Equal(t, []any{"a8m", "foo", "bar"}, args)
282 })
283}
284
285func TestFieldNotIn(t *testing.T) {
286 p := FieldNotIn("id", 1, 2, 3)

Callers

nothing calls this directly

Calls 7

DialectFunction · 0.85
RunMethod · 0.80
FieldInFunction · 0.70
TableFunction · 0.70
QueryMethod · 0.65
FromMethod · 0.45
SelectMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…