Skip to content

Commit

Permalink
don't reuse modifier, use table name instead
Browse files Browse the repository at this point in the history
  • Loading branch information
mtsoltan committed Aug 12, 2024
1 parent a1d9d7d commit c380166
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion callbacks/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func Delete(config *Config) func(db *gorm.DB) {
HandleJoins(
db,
func(db *gorm.DB) {
deleteClause.Modifier = db.Statement.Table
deleteClause.Table = db.Statement.Table
},
func(db *gorm.DB, tableAliasName string, idx int, relation *schema.Relationship) {
},
Expand Down
7 changes: 6 additions & 1 deletion clause/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package clause

type Delete struct {
Modifier string
Table string
}

func (d Delete) Name() string {
Expand All @@ -13,7 +14,11 @@ func (d Delete) Build(builder Builder) {

if d.Modifier != "" {
builder.WriteByte(' ')
builder.WriteQuoted(d.Modifier)
builder.WriteString(d.Modifier)
}
if d.Table != "" {
builder.WriteByte(' ')
builder.WriteQuoted(d.Table)
}
}

Expand Down

0 comments on commit c380166

Please sign in to comment.