From f36d20503d1dec368c81ffbc9706a57df2250b8a Mon Sep 17 00:00:00 2001 From: Alexey Orlenko Date: Wed, 10 Jul 2024 17:48:41 +0200 Subject: [PATCH] feat: encode path differently --- .../dmmf/src/ast_builders/datamodel_ast_builder.rs | 5 +++-- query-engine/dmmf/src/serialization_ast/datamodel_ast.rs | 7 ++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/query-engine/dmmf/src/ast_builders/datamodel_ast_builder.rs b/query-engine/dmmf/src/ast_builders/datamodel_ast_builder.rs index 17ee7fe12c2..58bcb1c7ebd 100644 --- a/query-engine/dmmf/src/ast_builders/datamodel_ast_builder.rs +++ b/query-engine/dmmf/src/ast_builders/datamodel_ast_builder.rs @@ -257,8 +257,9 @@ fn model_indexes_to_dmmf(model: walkers::ModelWalker<'_>) -> impl Iterator field_name.to_owned(), + Some(type_name) => format!("{type_name}.{field_name}"), }) .collect(), sort_order: sfa.sort_order().map(Into::into), diff --git a/query-engine/dmmf/src/serialization_ast/datamodel_ast.rs b/query-engine/dmmf/src/serialization_ast/datamodel_ast.rs index b988d69829b..bbda7f06a49 100644 --- a/query-engine/dmmf/src/serialization_ast/datamodel_ast.rs +++ b/query-engine/dmmf/src/serialization_ast/datamodel_ast.rs @@ -129,9 +129,10 @@ pub struct Index { #[derive(Debug, serde::Serialize)] #[serde(rename_all = "camelCase")] pub struct IndexField { - /// Path to the indexed field. Each tuple consists of the field name and - /// the name of the type this field is defined on. - pub path: Vec<(String, String)>, + /// Path to the indexed field. If the field is defined on the model, only its name is + /// specified. If it is defined on a composite type, it is specified in the format + /// `CompositeType.fieldName` (and the consumer of the DMMF may need to split it). + pub path: Vec, #[serde(skip_serializing_if = "Option::is_none")] pub sort_order: Option, #[serde(skip_serializing_if = "Option::is_none")]