You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
a.Equal("WITH temp_user AS (SELECT id FROM inactive_users) DELETE FROM user, temp_user WHERE user.id IN (SELECT id FROM temp_user) RETURNING id, deleted_at", sql)
195
195
}
196
196
197
+
funcExampleDeleteBuilder_Using() {
198
+
db:=NewDeleteBuilder()
199
+
db.DeleteFrom("orders")
200
+
db.Using("customers")
201
+
db.Where(
202
+
"orders.customer_id = customers.id",
203
+
db.Equal("customers.status", "inactive"),
204
+
)
205
+
206
+
sql, args:=db.BuildWithFlavor(PostgreSQL)
207
+
fmt.Println(sql)
208
+
fmt.Println(args)
209
+
210
+
// Output:
211
+
// DELETE FROM orders USING customers WHERE orders.customer_id = customers.id AND customers.status = $1
212
+
// [inactive]
213
+
}
214
+
215
+
funcTestDeleteBuilderUsing(t*testing.T) {
216
+
a:=assert.New(t)
217
+
218
+
// Single USING table
219
+
db:=NewDeleteBuilder()
220
+
db.DeleteFrom("orders")
221
+
db.Using("customers")
222
+
db.Where("orders.customer_id = customers.id")
223
+
224
+
sql, _:=db.BuildWithFlavor(PostgreSQL)
225
+
a.Equal("DELETE FROM orders USING customers WHERE orders.customer_id = customers.id", sql)
0 commit comments