feat: ent update fields.
This commit is contained in:
28
entgo/update/update_test.go
Normal file
28
entgo/update/update_test.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package update
|
||||
|
||||
import (
|
||||
"entgo.io/ent/dialect"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"github.com/stretchr/testify/require"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestBuildSetNullUpdate(t *testing.T) {
|
||||
t.Run("MySQL_Set2", func(t *testing.T) {
|
||||
s := sql.Dialect(dialect.MySQL).Update("users")
|
||||
|
||||
BuildSetNullUpdate(s, []string{"id", "username"})
|
||||
query, args := s.Query()
|
||||
require.Equal(t, "UPDATE `users` SET `id` = NULL, `username` = NULL", query)
|
||||
require.Empty(t, args)
|
||||
|
||||
})
|
||||
t.Run("PostgreSQL_Set2", func(t *testing.T) {
|
||||
s := sql.Dialect(dialect.Postgres).Update("users")
|
||||
|
||||
BuildSetNullUpdate(s, []string{"id", "username"})
|
||||
query, args := s.Query()
|
||||
require.Equal(t, `UPDATE "users" SET "id" = NULL, "username" = NULL`, query)
|
||||
require.Empty(t, args)
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user