diff --git a/crates/query-engine/translation/tests/goldenfiles/mutations/insert/configuration.json b/crates/query-engine/translation/tests/goldenfiles/mutations/v2_insert/configuration.json similarity index 100% rename from crates/query-engine/translation/tests/goldenfiles/mutations/insert/configuration.json rename to crates/query-engine/translation/tests/goldenfiles/mutations/v2_insert/configuration.json diff --git a/crates/query-engine/translation/tests/goldenfiles/mutations/insert/request.json b/crates/query-engine/translation/tests/goldenfiles/mutations/v2_insert/request.json similarity index 97% rename from crates/query-engine/translation/tests/goldenfiles/mutations/insert/request.json rename to crates/query-engine/translation/tests/goldenfiles/mutations/v2_insert/request.json index 3604ad116..6dc2970f1 100644 --- a/crates/query-engine/translation/tests/goldenfiles/mutations/insert/request.json +++ b/crates/query-engine/translation/tests/goldenfiles/mutations/v2_insert/request.json @@ -2,7 +2,7 @@ "operations": [ { "type": "procedure", - "name": "insert_Artist", + "name": "v2_insert_Artist", "arguments": { "objects": [ { diff --git a/crates/query-engine/translation/tests/goldenfiles/mutations/insert_empty_objects/configuration.json b/crates/query-engine/translation/tests/goldenfiles/mutations/v2_insert_empty_objects/configuration.json similarity index 100% rename from crates/query-engine/translation/tests/goldenfiles/mutations/insert_empty_objects/configuration.json rename to crates/query-engine/translation/tests/goldenfiles/mutations/v2_insert_empty_objects/configuration.json diff --git a/crates/query-engine/translation/tests/goldenfiles/mutations/insert_empty_objects/request.json b/crates/query-engine/translation/tests/goldenfiles/mutations/v2_insert_empty_objects/request.json similarity index 96% rename from crates/query-engine/translation/tests/goldenfiles/mutations/insert_empty_objects/request.json rename to crates/query-engine/translation/tests/goldenfiles/mutations/v2_insert_empty_objects/request.json index 522f2c8cb..183a7855e 100644 --- a/crates/query-engine/translation/tests/goldenfiles/mutations/insert_empty_objects/request.json +++ b/crates/query-engine/translation/tests/goldenfiles/mutations/v2_insert_empty_objects/request.json @@ -2,7 +2,7 @@ "operations": [ { "type": "procedure", - "name": "insert_Dog", + "name": "v2_insert_Dog", "arguments": { "objects": [{}, {}, {}, {}], "post_check": { diff --git a/crates/query-engine/translation/tests/snapshots/tests__mutations__v2_insert.snap b/crates/query-engine/translation/tests/snapshots/tests__mutations__v2_insert.snap new file mode 100644 index 000000000..5fe545d27 --- /dev/null +++ b/crates/query-engine/translation/tests/snapshots/tests__mutations__v2_insert.snap @@ -0,0 +1,62 @@ +--- +source: crates/query-engine/translation/tests/tests.rs +expression: result +--- +BEGIN +ISOLATION LEVEL READ COMMITTED READ WRITE; + +WITH "%0_generated_mutation" AS ( + INSERT INTO + "public"."Artist"("ArtistId", "Name") + VALUES + (276, cast($1 as "pg_catalog"."varchar")), + (DEFAULT, cast($2 as "pg_catalog"."varchar")) RETURNING *, + false AS "%check__constraint" +) +SELECT + ( + SELECT + json_build_object('result', row_to_json("%4_universe"), 'type', $3) AS "universe" + FROM + ( + SELECT + * + FROM + ( + SELECT + coalesce(json_agg(row_to_json("%5_returning")), '[]') AS "returning" + FROM + ( + SELECT + "%1_Artist"."ArtistId" AS "artist_id", + "%1_Artist"."Name" AS "name" + FROM + "%0_generated_mutation" AS "%1_Artist" + ) AS "%5_returning" + ) AS "%5_returning" + CROSS JOIN ( + SELECT + COUNT(*) AS "affected_rows" + FROM + ( + SELECT + "%2_Artist".* + FROM + "%0_generated_mutation" AS "%2_Artist" + ) AS "%3_Artist" + ) AS "%6_aggregates" + ) AS "%4_universe" + ) AS "%results", + ( + SELECT + coalesce( + bool_and("%7_v2_insert_Artist"."%check__constraint"), + true + ) AS "%check__constraint" + FROM + "%0_generated_mutation" AS "%7_v2_insert_Artist" + ) AS "%check__constraint"; + +COMMIT; + +[[(1, String("Olympians")), (2, String("The Other Band")), (3, String("procedure"))]] diff --git a/crates/query-engine/translation/tests/snapshots/tests__mutations__v2_insert_empty_objects.snap b/crates/query-engine/translation/tests/snapshots/tests__mutations__v2_insert_empty_objects.snap new file mode 100644 index 000000000..d1c6d711e --- /dev/null +++ b/crates/query-engine/translation/tests/snapshots/tests__mutations__v2_insert_empty_objects.snap @@ -0,0 +1,62 @@ +--- +source: crates/query-engine/translation/tests/tests.rs +expression: result +--- +BEGIN +ISOLATION LEVEL READ COMMITTED READ WRITE; + +WITH "%0_generated_mutation" AS ( + INSERT INTO + "public"."Dog" + SELECT + FROM + generate_series(1, 4) RETURNING *, + true AS "%check__constraint" +) +SELECT + ( + SELECT + json_build_object('result', row_to_json("%4_universe"), 'type', $1) AS "universe" + FROM + ( + SELECT + * + FROM + ( + SELECT + coalesce(json_agg(row_to_json("%5_returning")), '[]') AS "returning" + FROM + ( + SELECT + "%1_Dog"."id" AS "id", + "%1_Dog"."adopter_name" AS "adopter_name" + FROM + "%0_generated_mutation" AS "%1_Dog" + ) AS "%5_returning" + ) AS "%5_returning" + CROSS JOIN ( + SELECT + COUNT(*) AS "affected_rows" + FROM + ( + SELECT + "%2_Dog".* + FROM + "%0_generated_mutation" AS "%2_Dog" + ) AS "%3_Dog" + ) AS "%6_aggregates" + ) AS "%4_universe" + ) AS "%results", + ( + SELECT + coalesce( + bool_and("%7_v2_insert_Dog"."%check__constraint"), + true + ) AS "%check__constraint" + FROM + "%0_generated_mutation" AS "%7_v2_insert_Dog" + ) AS "%check__constraint"; + +COMMIT; + +[[(1, String("procedure"))]]