add test for repeated target filtering
@@ -128,30 +128,30 @@ fn test_upsert() {
];
let upsert_command_single_where = insert_into(users)
- .values(values)
+ .values(&values)
.on_conflict(hair_color)
- .filter_target(hair_color.eq(Some("black")))
+ .filter_target(hair_color.eq("black"))
.do_nothing();
let upsert_single_where_sql_display =
debug_query::<TestBackend, _>(&upsert_command_single_where).to_string();
assert_eq!(
upsert_single_where_sql_display,
- r#"INSERT INTO "users" ("name", "hair_color") VALUES ($1, $2), ($3, $4) ON CONFLICT ("hair_color") WHERE "users"."hair_color" = $5 DO NOTHING -- binds: ["Sean", Some("black"), "Tess", None, Some("black")]"#
+ r#"INSERT INTO "users" ("name", "hair_color") VALUES ($1, $2), ($3, $4) ON CONFLICT ("hair_color") WHERE "users"."hair_color" = $5 DO NOTHING -- binds: ["Sean", Some("black"), "Tess", None, "black"]"#
);
- // let upsert_command_second_where = insert_into(users)
- // .values(values)
- // .on_conflict(hair_color)
- // .filter_target(name.eq(Some("Sean")))
- // .filter_target(hair_color.eq(Some("black")))
- // .do_nothing();
+ let upsert_command_second_where = insert_into(users)
+ .values(&values)
+ .on_conflict(hair_color)
+ .filter_target(hair_color.eq("black"))
+ .filter_target(name.eq("Sean"))
+ .do_nothing();
- // let upsert_second_where_sql_display =
- // debug_query::<TestBackend, _>(&upsert_command_second_where).to_string();
+ let upsert_second_where_sql_display =
+ debug_query::<TestBackend, _>(&upsert_command_second_where).to_string();
- // assert_eq!(
- // upsert_second_where_sql_display,
- // r#"INSERT INTO "users" ("name", "hair_color") VALUES ($1, $2), ($3, $4) ON CONFLICT ("hair_color") WHERE "users"."hair_color" = $5 and WHERE "users"."name" = $6 DO NOTHING -- binds: ["Sean", Some("black"), "Tess", None, Some("black"), Some("Sean")]"#
- // );
+ assert_eq!(
+ upsert_second_where_sql_display,
+ r#"INSERT INTO "users" ("name", "hair_color") VALUES ($1, $2), ($3, $4) ON CONFLICT ("hair_color") WHERE "users"."hair_color" = $5 AND "users"."name" = $6 DO NOTHING -- binds: ["Sean", Some("black"), "Tess", None, "black", "Sean"]"#
+ );
}
