From 64bb6b95cbf89b742d0a4cbcbebffc973942e7ad Mon Sep 17 00:00:00 2001 From: Serhii Tatarintsev Date: Wed, 29 May 2024 12:12:43 +0200 Subject: [PATCH] Restore #4883 (#4891) * One half of the fix for: https://github.com/prisma/prisma/issues/23926 * Unexcludes pg, neon, and PS for the through_relations::common_types test * Instead of receiving pre-handled JSON by DAs, we now expect strings and will perform JSON parsing in Quaint. * Removed special handling for "$__prisma_null" due to the aforementioned * Temporarily disable wasm-benchmarks due to breaking change in engines <-> DA contract. To be re-enabled and re-evaluated in a follow-up PR per convo with @sevinf --------- Co-authored-by: Sophie <29753584+Druue@users.noreply.github.com> --- .github/workflows/wasm-benchmarks.yml | 9 +++++++-- .../tests/queries/data_types/through_relation.rs | 8 +------- .../src/database/operations/read/coerce.rs | 5 +++++ .../driver-adapters/src/conversion/js_to_quaint.rs | 5 +++-- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/.github/workflows/wasm-benchmarks.yml b/.github/workflows/wasm-benchmarks.yml index 4aceeeb7f857..160abfaf5b50 100644 --- a/.github/workflows/wasm-benchmarks.yml +++ b/.github/workflows/wasm-benchmarks.yml @@ -59,6 +59,7 @@ jobs: - name: Run benchmarks id: bench + if: false run: | make run-bench | tee results.txt @@ -122,6 +123,7 @@ jobs: echo EOF } >> "$GITHUB_OUTPUT" - name: Find past report comment + if: false uses: peter-evans/find-comment@v3 id: findReportComment with: @@ -132,7 +134,9 @@ jobs: uses: peter-evans/create-or-update-comment@v4 # Only run on branches from our repository # It avoids an expected failure on forks - if: ${{ github.event.pull_request.head.repo.full_name == github.repository }} + # if: ${{ github.event.pull_request.head.repo.full_name == github.repository }} + if: false + with: comment-id: ${{ steps.findReportComment.outputs.comment-id }} issue-number: ${{ github.event.pull_request.number }} @@ -152,7 +156,8 @@ jobs: edit-mode: replace - name: Fail workflow if regression detected - if: steps.bench.outputs.status == 'failed' + # if: steps.bench.outputs.status == 'failed' + if: false run: | echo "Workflow failed due to benchmark regression." exit 1 diff --git a/query-engine/connector-test-kit-rs/query-engine-tests/tests/queries/data_types/through_relation.rs b/query-engine/connector-test-kit-rs/query-engine-tests/tests/queries/data_types/through_relation.rs index a17d346674c0..85389968417f 100644 --- a/query-engine/connector-test-kit-rs/query-engine-tests/tests/queries/data_types/through_relation.rs +++ b/query-engine/connector-test-kit-rs/query-engine-tests/tests/queries/data_types/through_relation.rs @@ -31,13 +31,7 @@ mod scalar_relations { schema.to_owned() } - // TODO: fix https://github.com/prisma/team-orm/issues/684 and unexclude DAs. - // On napi, this currently fails with "P2023": - // `Inconsistent column data: Unexpected conversion failure for field Child.bInt from Number(14324324234324.0) to BigInt`. - #[connector_test( - schema(schema_common), - exclude(Postgres("pg.js", "neon.js"), Vitess("planetscale.js")) - )] + #[connector_test(schema(schema_common))] async fn common_types(runner: Runner) -> TestResult<()> { create_common_children(&runner).await?; diff --git a/query-engine/connectors/sql-query-connector/src/database/operations/read/coerce.rs b/query-engine/connectors/sql-query-connector/src/database/operations/read/coerce.rs index d69a32940dfa..cb834cb25763 100644 --- a/query-engine/connectors/sql-query-connector/src/database/operations/read/coerce.rs +++ b/query-engine/connectors/sql-query-connector/src/database/operations/read/coerce.rs @@ -111,6 +111,11 @@ fn coerce_json_relation_to_pv(value: serde_json::Value, rs: &RelationSelection) Ok(PrismaValue::Object(map)) } + serde_json::Value::String(s) => { + let v = serde_json::from_str(&s)?; + + coerce_json_relation_to_pv(v, rs) + } x => unreachable!("Unexpected value when deserializing JSON relation data: {x:?}"), } } diff --git a/query-engine/driver-adapters/src/conversion/js_to_quaint.rs b/query-engine/driver-adapters/src/conversion/js_to_quaint.rs index b723cced716e..dd18d5e72fc3 100644 --- a/query-engine/driver-adapters/src/conversion/js_to_quaint.rs +++ b/query-engine/driver-adapters/src/conversion/js_to_quaint.rs @@ -217,8 +217,9 @@ pub fn js_value_to_quaint( match json_value { // DbNull serde_json::Value::Null => Ok(QuaintValue::null_json()), - // JsonNull - serde_json::Value::String(s) if s == "$__prisma_null" => Ok(QuaintValue::json(serde_json::Value::Null)), + serde_json::Value::String(s) => serde_json::from_str(&s) + .map_err(|_| conversion_error!("Failed to parse incoming json from a driver adapter")) + .map(QuaintValue::json), json => Ok(QuaintValue::json(json)), } }