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
fix: validate integers to prevent overflow #3231
Conversation
5b57cab
to
4b79345
Compare
impl std::fmt::Display for IntType { | ||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
match self { | ||
IntType::Signed8 => write!(f, "8-bit signed integer"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick (no need to fix now), but f.write_str("8-bit signed integer")
does the same and is easier on the compiler
(QueryValue::Int(i), ScalarType::Float) => Ok(PrismaValue::Float(BigDecimal::from(i))), | ||
(QueryValue::Int(i), ScalarType::Decimal) => Ok(PrismaValue::Float(BigDecimal::from(i))), | ||
(QueryValue::Int(i), ScalarType::BigInt) => Ok(PrismaValue::BigInt(i)), | ||
|
||
(QueryValue::Float(f), ScalarType::Float) => Ok(PrismaValue::Float(f)), | ||
(QueryValue::Float(f), ScalarType::Decimal) => Ok(PrismaValue::Float(f)), | ||
(QueryValue::Float(f), ScalarType::Int) => match f.to_i64() { | ||
(QueryValue::Float(f), ScalarType::Int(_)) => match f.to_i64() { | ||
Some(converted) => Ok(PrismaValue::Int(converted)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if there's a good place to persist that, but it would be good to document that we validate all integers except 64 bit integers because they are strings at the graphql level (IIUC).
e3ee62c
to
ff55d4b
Compare
Overview
internal doc
fixes prisma/prisma#13913