MCPcopy Create free account
hub / github.com/ent/ent / TestFieldIsNull

Function TestFieldIsNull

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

Source from the content-addressed store, hash-verified

13)
14
15func TestFieldIsNull(t *testing.T) {
16 p := FieldIsNull("name")
17 t.Run("MySQL", func(t *testing.T) {
18 s := Dialect(dialect.MySQL).Select("*").From(Table("users"))
19 p(s)
20 query, args := s.Query()
21 require.Equal(t, "SELECT * FROM `users` WHERE `users`.`name` IS NULL", query)
22 require.Empty(t, args)
23 })
24 t.Run("PostgreSQL", func(t *testing.T) {
25 s := Dialect(dialect.Postgres).Select("*").From(Table("users"))
26 p(s)
27 query, args := s.Query()
28 require.Equal(t, `SELECT * FROM "users" WHERE "users"."name" IS NULL`, query)
29 require.Empty(t, args)
30 })
31}
32
33func TestFieldNotNull(t *testing.T) {
34 p := FieldNotNull("name")

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected