From c907c8bbbc4b5a9696f07955176068ef1699159b Mon Sep 17 00:00:00 2001 From: Ariel Mashraki <7413593+a8m@users.noreply.github.com> Date: Sun, 23 Aug 2020 20:51:19 +0300 Subject: [PATCH] integ: add sqlite to json tests (#686) --- dialect/sql/builder.go | 6 +++--- entc/integration/json/json_test.go | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/dialect/sql/builder.go b/dialect/sql/builder.go index 58233144b..55d96cd76 100644 --- a/dialect/sql/builder.go +++ b/dialect/sql/builder.go @@ -1822,13 +1822,13 @@ type Builder struct { func (b *Builder) Quote(ident string) string { switch { case b.postgres(): - // if it was quoted with the wrong + // If it was quoted with the wrong // identifier character. if strings.Contains(ident, "`") { return strings.Replace(ident, "`", `"`, -1) } return strconv.Quote(ident) - // an identifier for unknown dialect. + // An identifier for unknown dialect. case b.dialect == "" && strings.ContainsAny(ident, "`\""): return ident default: @@ -1853,7 +1853,7 @@ func (b *Builder) Ident(s string) *Builder { case s != "*" && !b.isIdent(s) && !isFunc(s) && !isModifier(s): b.WriteString(b.Quote(s)) case (isFunc(s) || isModifier(s)) && b.postgres(): - // modifiers and aggregation functions that + // Modifiers and aggregation functions that // were called without dialect information. b.WriteString(strings.Replace(s, "`", `"`, -1)) default: diff --git a/entc/integration/json/json_test.go b/entc/integration/json/json_test.go index bc96e0680..d2cd67ecc 100644 --- a/entc/integration/json/json_test.go +++ b/entc/integration/json/json_test.go @@ -22,6 +22,7 @@ import ( "github.com/go-sql-driver/mysql" _ "github.com/lib/pq" + _ "github.com/mattn/go-sqlite3" "github.com/stretchr/testify/require" ) @@ -83,6 +84,21 @@ func TestPostgres(t *testing.T) { } } +func TestSQLite(t *testing.T) { + client, err := ent.Open("sqlite3", "file:ent?mode=memory&cache=shared&_fk=1") + require.NoError(t, err) + defer client.Close() + ctx := context.Background() + require.NoError(t, client.Schema.Create(ctx, migrate.WithGlobalUniqueID(true))) + + URL(t, client) + Dirs(t, client) + Ints(t, client) + Floats(t, client) + Strings(t, client) + RawMessage(t, client) +} + func Ints(t *testing.T, client *ent.Client) { ctx := context.Background() ints := []int{1, 2, 3}