diff --git a/bob.go b/bob.go index 001424d..18d48d2 100644 --- a/bob.go +++ b/bob.go @@ -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) -} \ No newline at end of file +} diff --git a/create_index.go b/create_index.go index ab008b3..3885361 100644 --- a/create_index.go +++ b/create_index.go @@ -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 -} \ No newline at end of file +} diff --git a/create_index_test.go b/create_index_test.go index daa499b..ef32966 100644 --- a/create_index_test.go +++ b/create_index_test.go @@ -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()) } }) -} \ No newline at end of file +} diff --git a/upsert_test.go b/upsert_test.go index 317ae8a..3dcb52d 100644 --- a/upsert_test.go +++ b/upsert_test.go @@ -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) } }) -} \ No newline at end of file +}