dialect/sql/entsql: allow non incremental primary keys (#1074)

* Allow non incremental PKs

* Format code with gofmt

* Update entc/integration/config/config_test.go

Co-authored-by: Ariel Mashraki <7413593+a8m@users.noreply.github.com>

* Update entc/integration/config/config_test.go

Co-authored-by: Ariel Mashraki <7413593+a8m@users.noreply.github.com>

* Update entc/integration/config/config_test.go

Co-authored-by: Ariel Mashraki <7413593+a8m@users.noreply.github.com>

* Update entc/integration/config/config_test.go

Co-authored-by: Ariel Mashraki <7413593+a8m@users.noreply.github.com>

* Sort imports

Co-authored-by: Ariel Mashraki <7413593+a8m@users.noreply.github.com>
This commit is contained in:
Santi Aguilera
2020-12-28 12:34:27 -03:00
committed by GitHub
parent b0841fc415
commit 75d93200e9
10 changed files with 100 additions and 13 deletions

View File

@@ -129,7 +129,7 @@ func (*SQLite) cType(c *Column) (t string) {
func (d *SQLite) addColumn(c *Column) *sql.ColumnBuilder {
b := sql.Column(c.Name).Type(d.cType(c)).Attr(c.Attr)
c.unique(b)
if c.Increment {
if c.PrimaryKey() && c.Increment {
b.Attr("PRIMARY KEY AUTOINCREMENT")
}
c.nullable(b)