From 7eecf9a728e2d152440dd4cae9630242f9567de2 Mon Sep 17 00:00:00 2001 From: Stanislas Michalak Date: Tue, 21 Aug 2018 13:11:15 +0200 Subject: [PATCH] Make sure SQLite accept both int and integer as pk (#22) * 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 --- translators/sqlite.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/translators/sqlite.go b/translators/sqlite.go index 421b56d8..c7ae4e8f 100644 --- a/translators/sqlite.go +++ b/translators/sqlite.go @@ -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)