Skip to content

Commit

Permalink
Make sure SQLite accept both int and integer as pk (#22)
Browse files Browse the repository at this point in the history
* Make sure SQLite accept both int and integer as pk

This is the behavior for the others drivers, there is no reason to
discriminate SQLite.

* SQLite: Return an error if the pk type is not supported
  • Loading branch information
stanislas-m authored Aug 21, 2018
1 parent f3f4d6f commit 7eecf9a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion translators/sqlite.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,12 @@ func (p *SQLite) CreateTable(t fizz.Table) (string, error) {
for _, c := range t.Columns {
if c.Primary {
switch strings.ToLower(c.ColType) {
case "integer":
case "integer", "int":
s = fmt.Sprintf("\"%s\" INTEGER PRIMARY KEY AUTOINCREMENT", c.Name)
case "uuid", "string":
s = fmt.Sprintf("\"%s\" TEXT PRIMARY KEY", c.Name)
default:
return "", errors.Errorf("can not use %s as a primary key", c.ColType)
}
} else {
s = p.buildColumn(c)
Expand Down

0 comments on commit 7eecf9a

Please sign in to comment.