From 7c4f5e7f9e1ae47004a046769fd5dc55248b7064 Mon Sep 17 00:00:00 2001 From: garren smith Date: Wed, 1 Dec 2021 15:15:22 +0200 Subject: [PATCH] support unsigned int type --- Cargo.lock | 2 +- Cargo.toml | 3 +++ libs/prisma-value/src/sql_ext.rs | 7 +++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 53e9b190f3e3..2990aeddf4eb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3245,7 +3245,7 @@ dependencies = [ [[package]] name = "quaint" version = "0.2.0-alpha.13" -source = "git+https://github.com/prisma/quaint#05eb0acc841eeb88569d1538c35b66b5e4f83266" +source = "git+https://github.com/serejkaaa512/quaint/?branch=feature/unsigned_int#b838af33a24d1ff5312b71e04e64c71e7ac52a1d" dependencies = [ "async-trait", "base64 0.12.3", diff --git a/Cargo.toml b/Cargo.toml index 563c27eee2b2..45685693e63f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -48,3 +48,6 @@ opt-level = 3 codegen-units = 1 opt-level = 'z' # Optimize for size. #strip="symbols" + +[patch."https://github.com/prisma/quaint"] +quaint = {git = 'https://github.com/serejkaaa512/quaint/', branch = 'feature/unsigned_int' } \ No newline at end of file diff --git a/libs/prisma-value/src/sql_ext.rs b/libs/prisma-value/src/sql_ext.rs index fc7129cbd72e..cf703d252e0e 100644 --- a/libs/prisma-value/src/sql_ext.rs +++ b/libs/prisma-value/src/sql_ext.rs @@ -11,6 +11,13 @@ impl<'a> TryFrom> for PrismaValue { let val = match pv { Value::Integer(i) => i.map(PrismaValue::Int).unwrap_or(PrismaValue::Null), + Value::UnsignedInteger(Some(u)) => match i64::try_from(u) { + Ok(i) => PrismaValue::Int(i), + Err(_) => return Err(crate::ConversionFailure { from: "u64", to: "i64" }), + }, + + Value::UnsignedInteger(None) => PrismaValue::Null, + Value::Float(Some(f)) => match f { f if f.is_nan() => { return Err(crate::ConversionFailure {