Skip to content

Commit

Permalink
Merge pull request uptrace#43 from j2gg0s/mysql-insert-without-alias
Browse files Browse the repository at this point in the history
insert: mysql does not support insert with alis
  • Loading branch information
vmihailenco authored Jun 30, 2021
2 parents f60ca22 + e65fc3a commit a0da3d0
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 a0da3d0

Please sign in to comment.