Skip to content

Commit

Permalink
feat: encode path differently
Browse files Browse the repository at this point in the history
  • Loading branch information
aqrln committed Jul 10, 2024
1 parent d1e2e9a commit f36d205
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
5 changes: 3 additions & 2 deletions query-engine/dmmf/src/ast_builders/datamodel_ast_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,9 @@ fn model_indexes_to_dmmf(model: walkers::ModelWalker<'_>) -> impl Iterator<Item
path: sfa
.as_path_to_indexed_field()
.into_iter()
.map(|(field_name, type_name)| {
(field_name.to_owned(), type_name.unwrap_or(model.name()).to_owned())
.map(|(field_name, type_name)| match type_name {
None => field_name.to_owned(),
Some(type_name) => format!("{type_name}.{field_name}"),
})
.collect(),
sort_order: sfa.sort_order().map(Into::into),
Expand Down
7 changes: 4 additions & 3 deletions query-engine/dmmf/src/serialization_ast/datamodel_ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub sort_order: Option<SortOrder>,
#[serde(skip_serializing_if = "Option::is_none")]
Expand Down

0 comments on commit f36d205

Please sign in to comment.