Skip to content

Commit

Permalink
add DO NOTHING
Browse files Browse the repository at this point in the history
  • Loading branch information
yinxulai committed Mar 24, 2024
1 parent 6434aeb commit e282cd7
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions insert.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,13 @@ func (s *insertBuilder) String() string {
sqlString += s.builder.join("", "(", s.statement.columns, ", ", ")")
sqlString += s.builder.join("VALUES", "(", s.statement.values, ", ", ")")

if len(s.statement.onConflict) > 0 && len(s.statement.doUpdateSet) > 0 {
if len(s.statement.onConflict) > 0 {
sqlString += s.builder.join("ON CONFLICT", "(", s.statement.onConflict, ", ", ")")
sqlString += s.builder.join("DO UPDATE SET", "", s.statement.doUpdateSet, ", ", "")
if len(s.statement.doUpdateSet) > 0 {
sqlString += s.builder.join("DO UPDATE SET", "", s.statement.doUpdateSet, ", ", "")
} else {
sqlString += s.builder.join("DO NOTHING", "", []string{}, "", "")
}
}

return strings.Trim(sqlString, " ")
Expand Down

0 comments on commit e282cd7

Please sign in to comment.