mirror of
https://github.com/ent/ent.git
synced 2026-05-22 09:31:45 +03:00
dialect/sql/sqlgraph: changing the M2M creation semantic from Add to Connect
Thus, calling AddE with the same edge values, ignore and not throw an error. For edge-schemas with extra fields, we maintain the same logic because we cannot determine if the extra fields have different values that what exist in the database
This commit is contained in:
committed by
Ariel Mashraki
parent
4c9d61cf16
commit
aa3d21f01a
@@ -777,7 +777,7 @@ func ConflictWhere(p *Predicate) ConflictOption {
|
||||
}
|
||||
}
|
||||
|
||||
// UpdateWhere allows setting the an update condition. Only rows
|
||||
// UpdateWhere allows setting the update condition. Only rows
|
||||
// for which this expression returns true will be updated.
|
||||
func UpdateWhere(p *Predicate) ConflictOption {
|
||||
return func(c *conflict) {
|
||||
@@ -985,8 +985,10 @@ func (i *InsertBuilder) writeConflict(b *Builder) {
|
||||
switch i.Dialect() {
|
||||
case dialect.MySQL:
|
||||
b.WriteString(" ON DUPLICATE KEY UPDATE ")
|
||||
// Fallback to ResolveWithIgnore() as MySQL
|
||||
// does not support the "DO NOTHING" clause.
|
||||
if i.conflict.action.nothing {
|
||||
b.AddError(fmt.Errorf("invalid CONFLICT action ('DO NOTHING')"))
|
||||
i.OnConflict(ResolveWithIgnore())
|
||||
}
|
||||
case dialect.SQLite, dialect.Postgres:
|
||||
b.WriteString(" ON CONFLICT")
|
||||
|
||||
Reference in New Issue
Block a user