[chore] Update bun and sqlite dependencies (#478)

* update bun + sqlite versions

* step bun to v1.1.3
This commit is contained in:
tobi
2022-04-24 12:26:22 +02:00
committed by GitHub
parent 8d34d5af3c
commit 88979b35d4
246 changed files with 409690 additions and 148967 deletions

View File

@ -102,6 +102,21 @@ func (q *CreateTableQuery) TableSpace(tablespace string) *CreateTableQuery {
return q
}
func (q *CreateTableQuery) WithForeignKeys() *CreateTableQuery {
for _, relation := range q.tableModel.Table().Relations {
if relation.Type == schema.ManyToManyRelation ||
relation.Type == schema.HasManyRelation {
continue
}
q = q.ForeignKey("(?) REFERENCES ? (?)",
Safe(appendColumns(nil, "", relation.BaseFields)),
relation.JoinTable.SQLName,
Safe(appendColumns(nil, "", relation.JoinFields)),
)
}
return q
}
//------------------------------------------------------------------------------
func (q *CreateTableQuery) Operation() string {
@ -121,7 +136,7 @@ func (q *CreateTableQuery) AppendQuery(fmter schema.Formatter, b []byte) (_ []by
b = append(b, "TEMP "...)
}
b = append(b, "TABLE "...)
if q.ifNotExists {
if q.ifNotExists && fmter.Dialect().Features().Has(feature.TableNotExists) {
b = append(b, "IF NOT EXISTS "...)
}
b, err = q.appendFirstTable(fmter, b)
@ -142,8 +157,13 @@ func (q *CreateTableQuery) AppendQuery(fmter schema.Formatter, b []byte) (_ []by
if field.NotNull {
b = append(b, " NOT NULL"...)
}
if fmter.Dialect().Features().Has(feature.AutoIncrement) && field.AutoIncrement {
b = append(b, " AUTO_INCREMENT"...)
if field.AutoIncrement {
switch {
case fmter.Dialect().Features().Has(feature.AutoIncrement):
b = append(b, " AUTO_INCREMENT"...)
case fmter.Dialect().Features().Has(feature.Identity):
b = append(b, " IDENTITY"...)
}
}
if field.SQLDefault != "" {
b = append(b, " DEFAULT "...)