Skip to content

Commit 348a93d

Browse files
committed
inline parseColumns function
1 parent 8abaa12 commit 348a93d

File tree

1 file changed

+5
-17
lines changed

1 file changed

+5
-17
lines changed

Migration.go

+5-17
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package exodus
22

3-
import "fmt"
3+
import (
4+
"fmt"
5+
"strings"
6+
)
47

58
// Migration is a fully-formed SQL command that can be ran against
69
// a database connection.
@@ -15,7 +18,7 @@ type MigrationInterface interface {
1518
// Create generates an SQL command to create a table using the
1619
// schema provided.
1720
func Create(table string, schema Schema) Migration {
18-
sql := parseColumns(loadColumnSQL(schema))
21+
sql := strings.Join(loadColumnSQL(schema), ", ")
1922

2023
return Migration(fmt.Sprintf("CREATE TABLE %s ( %s );", table, sql))
2124
}
@@ -36,18 +39,3 @@ func loadColumnSQL(schema Schema) (commands []string) {
3639

3740
return
3841
}
39-
40-
// parseColumns implodes the slice of SQL commands into a
41-
// single string containing all the column definitions.
42-
func parseColumns(sql []string) (formatted string) {
43-
for i, command := range sql {
44-
formatted = formatted + command
45-
// If it is not the last column, add ", " after the
46-
// formatted string.
47-
if i != len(sql)-1 {
48-
formatted = formatted + ", "
49-
}
50-
}
51-
52-
return
53-
}

0 commit comments

Comments
 (0)