Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(driver-adapters): fix bigint handling on creation and filter #4648

Merged
merged 7 commits into from
Jan 22, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ mod max_integer {
schema.to_owned()
}

// Info: `driver-adapters` are currently excluded because they yield a different error message,
// coming straight from the database.
#[connector_test(
schema(overflow_pg),
only(Postgres),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@ mod bigint {
}

// "Using a BigInt field" should "work"
#[connector_test(exclude(
Postgres("pg.js.wasm", "neon.js.wasm"),
Sqlite("libsql.js.wasm"),
Vitess("planetscale.js.wasm")
))]
#[connector_test()]
async fn using_bigint_field(runner: Runner) -> TestResult<()> {
insta::assert_snapshot!(
run_query!(&runner, r#"mutation {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ mod postgres {
}

//"Postgres native int types" should "work"
#[connector_test(schema(schema_int), only(Postgres), exclude(Postgres("pg.js.wasm", "neon.js.wasm")))]
#[connector_test(schema(schema_int), only(Postgres))]
async fn native_int_types(runner: Runner) -> TestResult<()> {
insta::assert_snapshot!(
run_query!(&runner, r#"mutation {
Expand Down
11 changes: 7 additions & 4 deletions query-engine/driver-adapters/src/wasm/adapter_method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@ use super::error::into_quaint_error;
use super::from_js::FromJsValue;
use crate::AdapterResult;

// `serialize_missing_as_null` is required to make sure that "empty" values (e.g., `None` and `()`)
// are serialized as `null` and not `undefined`.
// This is due to certain drivers (e.g., LibSQL) not supporting `undefined` values.
pub(crate) static SERIALIZER: Serializer = Serializer::new().serialize_missing_as_null(true);
// - `serialize_missing_as_null` is required to make sure that "empty" values (e.g., `None` and `()`)
// are serialized as `null` and not `undefined`.
// This is due to certain drivers (e.g., LibSQL) not supporting `undefined` values.
// - `serialize_large_number_types_as_bigints` is required to allow reading bigints from Prisma Client.
pub(crate) static SERIALIZER: Serializer = Serializer::new()
.serialize_large_number_types_as_bigints(true)
.serialize_missing_as_null(true);

#[derive(Clone)]
pub(crate) struct AdapterMethod<ArgType, ReturnType>
Expand Down
Loading