Skip to content

Commit

Permalink
feat: add relation_on_update field to DMMF model (#5118)
Browse files Browse the repository at this point in the history
  • Loading branch information
WhyAsh5114 authored Jan 11, 2025
1 parent 66ff515 commit c571c6d
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 8 deletions.
3 changes: 3 additions & 0 deletions query-engine/dmmf/src/ast_builders/datamodel_ast_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ fn composite_type_field_to_dmmf(field: walkers::CompositeTypeFieldWalker<'_>) ->
relation_from_fields: None,
relation_to_fields: None,
relation_on_delete: None,
relation_on_update: None,
field_type: match field.r#type() {
ScalarFieldType::CompositeType(ct) => field.walk(ct).name().to_owned(),
ScalarFieldType::Enum(enm) => field.walk(enm).name().to_owned(),
Expand Down Expand Up @@ -210,6 +211,7 @@ fn scalar_field_to_dmmf(field: walkers::ScalarFieldWalker<'_>) -> Field {
relation_from_fields: None,
relation_to_fields: None,
relation_on_delete: None,
relation_on_update: None,
is_generated: Some(false),
is_updated_at: Some(field.is_updated_at()),
documentation: ast_field.documentation().map(ToOwned::to_owned),
Expand Down Expand Up @@ -245,6 +247,7 @@ fn relation_field_to_dmmf(field: walkers::RelationFieldWalker<'_>) -> Field {
.unwrap_or_default(),
),
relation_on_delete: field.explicit_on_delete().map(|od| od.to_string()),
relation_on_update: field.explicit_on_update().map(|ou| ou.to_string()),
is_generated: Some(false),
is_updated_at: Some(false),
documentation: ast_field.documentation().map(ToOwned::to_owned),
Expand Down
3 changes: 3 additions & 0 deletions query-engine/dmmf/src/serialization_ast/datamodel_ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ pub struct Field {
#[serde(skip_serializing_if = "Option::is_none")]
pub relation_on_delete: Option<String>,

#[serde(skip_serializing_if = "Option::is_none")]
pub relation_on_update: Option<String>,

#[serde(skip_serializing_if = "Option::is_none")]
pub is_generated: Option<bool>,

Expand Down
Binary file not shown.
30 changes: 22 additions & 8 deletions query-engine/dmmf/test_files/functions.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@
"nativeType": null,
"default": {
"name": "cuid",
"args": [1]
"args": [
1
]
},
"isGenerated": false,
"isUpdatedAt": false
Expand All @@ -87,7 +89,9 @@
"nativeType": null,
"default": {
"name": "cuid",
"args": [1]
"args": [
1
]
},
"isGenerated": false,
"isUpdatedAt": false
Expand All @@ -105,7 +109,9 @@
"nativeType": null,
"default": {
"name": "cuid",
"args": [2]
"args": [
2
]
},
"isGenerated": false,
"isUpdatedAt": false
Expand All @@ -123,7 +129,9 @@
"nativeType": null,
"default": {
"name": "uuid",
"args": [4]
"args": [
4
]
},
"isGenerated": false,
"isUpdatedAt": false
Expand All @@ -141,7 +149,9 @@
"nativeType": null,
"default": {
"name": "uuid",
"args": [4]
"args": [
4
]
},
"isGenerated": false,
"isUpdatedAt": false
Expand All @@ -159,7 +169,9 @@
"nativeType": null,
"default": {
"name": "uuid",
"args": [7]
"args": [
7
]
},
"isGenerated": false,
"isUpdatedAt": false
Expand Down Expand Up @@ -195,7 +207,9 @@
"nativeType": null,
"default": {
"name": "nanoid",
"args": [6]
"args": [
6
]
},
"isGenerated": false,
"isUpdatedAt": false
Expand Down Expand Up @@ -310,4 +324,4 @@
]
}
]
}
}

0 comments on commit c571c6d

Please sign in to comment.