MCPcopy
hub / github.com/ent/ent / TestFieldEQ

Function TestFieldEQ

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

Source from the content-addressed store, hash-verified

49}
50
51func TestFieldEQ(t *testing.T) {
52 p := FieldEQ("name", "a8m")
53 t.Run("MySQL", func(t *testing.T) {
54 s := Dialect(dialect.MySQL).Select("*").From(Table("users"))
55 p(s)
56 query, args := s.Query()
57 require.Equal(t, "SELECT * FROM `users` WHERE `users`.`name` = ?", query)
58 require.Equal(t, []any{"a8m"}, args)
59 })
60 t.Run("PostgreSQL", func(t *testing.T) {
61 s := Dialect(dialect.Postgres).Select("*").From(Table("users"))
62 p(s)
63 query, args := s.Query()
64 require.Equal(t, `SELECT * FROM "users" WHERE "users"."name" = $1`, query)
65 require.Equal(t, []any{"a8m"}, args)
66 })
67}
68
69func TestFieldsEQ(t *testing.T) {
70 p := FieldsEQ("create_time", "update_time")

Callers

nothing calls this directly

Calls 7

DialectFunction · 0.85
RunMethod · 0.80
FieldEQFunction · 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…