diff options
Diffstat (limited to 'vendor/github.com/uptrace/bun/dialect')
4 files changed, 26 insertions, 2 deletions
diff --git a/vendor/github.com/uptrace/bun/dialect/pgdialect/dialect.go b/vendor/github.com/uptrace/bun/dialect/pgdialect/dialect.go index 6ff85e166..f100e682c 100644 --- a/vendor/github.com/uptrace/bun/dialect/pgdialect/dialect.go +++ b/vendor/github.com/uptrace/bun/dialect/pgdialect/dialect.go @@ -108,3 +108,7 @@ func (d *Dialect) AppendUint32(b []byte, n uint32) []byte { func (d *Dialect) AppendUint64(b []byte, n uint64) []byte { return strconv.AppendInt(b, int64(n), 10) } + +func (d *Dialect) AppendSequence(b []byte, _ *schema.Table, _ *schema.Field) []byte { + return append(b, " GENERATED BY DEFAULT AS IDENTITY"...) +} diff --git a/vendor/github.com/uptrace/bun/dialect/pgdialect/version.go b/vendor/github.com/uptrace/bun/dialect/pgdialect/version.go index 9b3f8e228..c661534dc 100644 --- a/vendor/github.com/uptrace/bun/dialect/pgdialect/version.go +++ b/vendor/github.com/uptrace/bun/dialect/pgdialect/version.go @@ -2,5 +2,5 @@ package pgdialect // Version is the current release version. func Version() string { - return "1.1.16" + return "1.1.17" } diff --git a/vendor/github.com/uptrace/bun/dialect/sqlitedialect/dialect.go b/vendor/github.com/uptrace/bun/dialect/sqlitedialect/dialect.go index 3c809e7a7..3bfe500ff 100644 --- a/vendor/github.com/uptrace/bun/dialect/sqlitedialect/dialect.go +++ b/vendor/github.com/uptrace/bun/dialect/sqlitedialect/dialect.go @@ -39,6 +39,7 @@ func New() *Dialect { feature.InsertOnConflict | feature.TableNotExists | feature.SelectExists | + feature.AutoIncrement | feature.CompositeIn return d } @@ -91,6 +92,25 @@ func (d *Dialect) DefaultVarcharLen() int { return 0 } +// AppendSequence adds AUTOINCREMENT keyword to the column definition. As per [documentation], +// AUTOINCREMENT is only valid for INTEGER PRIMARY KEY, and this method will be a noop for other columns. +// +// Because this is a valid construct: +// CREATE TABLE ("id" INTEGER PRIMARY KEY AUTOINCREMENT); +// and this is not: +// CREATE TABLE ("id" INTEGER AUTOINCREMENT, PRIMARY KEY ("id")); +// AppendSequence adds a primary key constraint as a *side-effect*. Callers should expect it to avoid building invalid SQL. +// SQLite also [does not support] AUTOINCREMENT column in composite primary keys. +// +// [documentation]: https://www.sqlite.org/autoinc.html +// [does not support]: https://stackoverflow.com/a/6793274/14726116 +func (d *Dialect) AppendSequence(b []byte, table *schema.Table, field *schema.Field) []byte { + if field.IsPK && len(table.PKs) == 1 && field.CreateTableSQLType == sqltype.Integer { + b = append(b, " PRIMARY KEY AUTOINCREMENT"...) + } + return b +} + func fieldSQLType(field *schema.Field) string { switch field.DiscoveredSQLType { case sqltype.SmallInt, sqltype.BigInt: diff --git a/vendor/github.com/uptrace/bun/dialect/sqlitedialect/version.go b/vendor/github.com/uptrace/bun/dialect/sqlitedialect/version.go index 8baf8191f..216f16170 100644 --- a/vendor/github.com/uptrace/bun/dialect/sqlitedialect/version.go +++ b/vendor/github.com/uptrace/bun/dialect/sqlitedialect/version.go @@ -2,5 +2,5 @@ package sqlitedialect // Version is the current release version. func Version() string { - return "1.1.16" + return "1.1.17" } |