(oc *OnConflict)
| 1427 | } |
| 1428 | |
| 1429 | func onConflictSQL(oc *OnConflict) string { |
| 1430 | sb := getBuilder() |
| 1431 | defer putBuilder(sb) |
| 1432 | sb.WriteString(" ON CONFLICT") |
| 1433 | if len(oc.Target) > 0 { |
| 1434 | sb.WriteString(" (") |
| 1435 | sb.WriteString(exprListSQL(oc.Target)) |
| 1436 | sb.WriteString(")") |
| 1437 | } |
| 1438 | if oc.Constraint != "" { |
| 1439 | sb.WriteString(" ON CONSTRAINT ") |
| 1440 | sb.WriteString(oc.Constraint) |
| 1441 | } |
| 1442 | if oc.Action.DoNothing { |
| 1443 | sb.WriteString(" DO NOTHING") |
| 1444 | } else if len(oc.Action.DoUpdate) > 0 { |
| 1445 | sb.WriteString(" DO UPDATE SET ") |
| 1446 | upds := make([]string, len(oc.Action.DoUpdate)) |
| 1447 | for i, u := range oc.Action.DoUpdate { |
| 1448 | upds[i] = exprSQL(u.Column) + " = " + exprSQL(u.Value) |
| 1449 | } |
| 1450 | sb.WriteString(strings.Join(upds, ", ")) |
| 1451 | if oc.Action.Where != nil { |
| 1452 | sb.WriteString(" WHERE ") |
| 1453 | sb.WriteString(exprSQL(oc.Action.Where)) |
| 1454 | } |
| 1455 | } |
| 1456 | return sb.String() |
| 1457 | } |
| 1458 | |
| 1459 | func columnDefSQL(c *ColumnDef) string { |
| 1460 | sb := getBuilder() |
no test coverage detected