test:on duplicate update
This commit is contained in:
parent
e3fff64cec
commit
529a67dd8f
@ -34,7 +34,7 @@ func TestDuplicateScan(t *testing.T) {
|
|||||||
}
|
}
|
||||||
tx := DB.Begin()
|
tx := DB.Begin()
|
||||||
tx = tx.Table(dst.Name()).Clauses(clause.OnConflict{Columns: []clause.Column{{Name: "code"}}, DoUpdates: clause.Assignments(map[string]interface{}{"price": gorm.Expr("price + ?", dst.Price)})}).Create(dst)
|
tx = tx.Table(dst.Name()).Clauses(clause.OnConflict{Columns: []clause.Column{{Name: "code"}}, DoUpdates: clause.Assignments(map[string]interface{}{"price": gorm.Expr("price + ?", dst.Price)})}).Create(dst)
|
||||||
p := new(Product)
|
p := new(ProductD)
|
||||||
tx.Debug().Scan(&p)
|
tx.Debug().Scan(&p)
|
||||||
fmt.Printf("tx scan ||%+v\n", p)
|
fmt.Printf("tx scan ||%+v\n", p)
|
||||||
tx.Commit()
|
tx.Commit()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user