Skip to content

Commit

Permalink
insert: mysql does not support insert with alis
Browse files Browse the repository at this point in the history
  • Loading branch information
j2gg0s committed Jun 30, 2021
1 parent a275bc4 commit e65fc3a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions db.go
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,10 @@ func (db *DB) supportsDeleteTableAlias() bool {
return true
}

func (db *DB) supportsInsertTableAlias() bool {
return db.dialect.Name() != dialect.MySQL
}

func (db *DB) mysqlVersion() string {
db.mysql.versionOnce.Do(func() {
var version string
Expand Down
2 changes: 1 addition & 1 deletion query_insert.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ func (q *InsertQuery) AppendQuery(fmter schema.Formatter, b []byte) (_ []byte, e
}
b = append(b, "INTO "...)

if !q.onConflict.IsZero() {
if !q.onConflict.IsZero() && q.db.supportsInsertTableAlias() {
b, err = q.appendFirstTableWithAlias(fmter, b)
} else {
b, err = q.appendFirstTable(fmter, b)
Expand Down

0 comments on commit e65fc3a

Please sign in to comment.