chore: fmt

This commit is contained in:
Reinaldy Rafli 2021-11-09 12:16:31 +07:00
parent 070280bdf7
commit a891b58ffb
No known key found for this signature in database
GPG Key ID: CFDB9400255D8CB6
4 changed files with 18 additions and 18 deletions

2
bob.go
View File

@ -191,4 +191,4 @@ func CreateIndex(name string) IndexBuilder {
// CreateIndexIfNotExists creates an index with CreateIndexBuilder interface, if the index doesn't exists.
func CreateIndexIfNotExists(name string) IndexBuilder {
return BobStmtBuilder.CreateIndexIfNotExists(name)
}
}

View File

@ -10,18 +10,18 @@ import (
type IndexBuilder builder.Builder
type indexData struct {
Unique bool
Spatial bool
Fulltext bool
Name string
TableName string
Columns []IndexColumn
Unique bool
Spatial bool
Fulltext bool
Name string
TableName string
Columns []IndexColumn
IfNotExists bool
}
type IndexColumn struct {
Name string
Extras []string
Name string
Extras []string
Collate string
}
@ -76,7 +76,7 @@ func (i *indexData) ToSql() (sqlStr string, args []interface{}, err error) {
err = errors.New("should at least specify one column for create index statement")
return
}
var sql strings.Builder
sql.WriteString("CREATE ")
@ -121,7 +121,7 @@ func (i *indexData) ToSql() (sqlStr string, args []interface{}, err error) {
sql.WriteString("(")
sql.WriteString(strings.Join(columns, ", "))
sql.WriteString(");")
sqlStr = sql.String()
return
}
}

View File

@ -58,7 +58,7 @@ func TestCreateIndex_Error(t *testing.T) {
t.Fatal("error is not equal to result:", err.Error())
}
})
t.Run("without table name", func(t *testing.T) {
_, _, err := bob.
CreateIndex("name").
@ -88,4 +88,4 @@ func TestCreateIndex_Error(t *testing.T) {
t.Fatal("error is not equal to result:", err.Error())
}
})
}
}

View File

@ -189,10 +189,10 @@ func TestUpsert_WithoutReplacePlaceHolder(t *testing.T) {
if err != nil {
t.Error(err)
}
desiredSql := "IF NOT EXISTS (SELECT * FROM \"users\" WHERE \"email\" = @p1) INSERT INTO \"users\" (\"name\", \"email\") VALUES (@p2, @p3) ELSE UPDATE \"users\" SET \"name\" = @p4 WHERE \"email\" = @p5;"
desiredArgs := []interface{}{"john@doe.com", "John Doe", "john@doe.com", "John Does", "john@doe.com"}
if sql != desiredSql {
t.Error("sql is not the same as result: ", sql)
}
@ -200,7 +200,7 @@ func TestUpsert_WithoutReplacePlaceHolder(t *testing.T) {
t.Error("args is not the same as result: ", args)
}
})
t.Run("SQLite", func(t *testing.T) {
sql, args, err := bob.
Upsert("users", bob.SQLite).
@ -223,4 +223,4 @@ func TestUpsert_WithoutReplacePlaceHolder(t *testing.T) {
t.Error("args is not the same as result: ", args)
}
})
}
}