Skip to content

Commit

Permalink
fix(dmmf): [breaking] serialise uuid and cuid with proper args
Browse files Browse the repository at this point in the history
  • Loading branch information
jkomyno committed Nov 15, 2024
1 parent 195d25d commit 04af8ad
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ fn prisma_value_to_serde(value: &PrismaValue) -> serde_json::Value {
PrismaValue::Float(val) => {
serde_json::Value::Number(serde_json::Number::from_f64(val.to_f64().unwrap()).unwrap())
}
PrismaValue::Int(val) => serde_json::Value::Number(serde_json::Number::from_f64(*val as f64).unwrap()),
PrismaValue::Int(val) => serde_json::Value::Number(serde_json::Number::from(*val)),
PrismaValue::BigInt(val) => serde_json::Value::String(val.to_string()),
PrismaValue::DateTime(val) => serde_json::Value::String(val.to_rfc3339()),
PrismaValue::Null => serde_json::Value::Null,
Expand Down
Binary file not shown.
4 changes: 3 additions & 1 deletion query-engine/dmmf/test_files/functions.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@
"type": "String",
"default": {
"name": "cuid",
"args": []
"args": [
2
]
},
"isGenerated": false,
"isUpdatedAt": false
Expand Down
12 changes: 10 additions & 2 deletions query-engine/query-structure/src/default_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,19 @@ impl ValueGenerator {
}

pub fn new_cuid(version: u8) -> Self {
ValueGenerator::new(format!("cuid({version})"), vec![]).unwrap()
ValueGenerator::new(
format!("cuid"),

Check failure on line 187 in query-engine/query-structure/src/default_value.rs

View workflow job for this annotation

GitHub Actions / clippy linting

useless use of `format!`
vec![(Some(format!("{version}")), PrismaValue::Int(version as i64))],
)
.unwrap()
}

pub fn new_uuid(version: u8) -> Self {
ValueGenerator::new(format!("uuid({version})"), vec![]).unwrap()
ValueGenerator::new(
format!("uuid"),

Check failure on line 195 in query-engine/query-structure/src/default_value.rs

View workflow job for this annotation

GitHub Actions / clippy linting

useless use of `format!`
vec![(Some(format!("{version}")), PrismaValue::Int(version as i64))],
)
.unwrap()
}

pub fn new_nanoid(length: Option<u8>) -> Self {
Expand Down

0 comments on commit 04af8ad

Please sign in to comment.