Skip to content

Commit a2b481b

Browse files
authored
fix: update mongo snapshots and revert cruet change (#5674)
MongoDB tests were failing on `main` after [updating the driver to resolve a security issue](#5668) and [switching to `cruet` for case conversion](#5663). It wasn't caught in the corresponding pull requests because we don't run the MongoDB tests by default in PRs, they need to be opted into by using the `/test-all` command. Snapshots need to be updated in the MongoDB introspection tests because, due to a [bugfix upstream](mongodb/mongo-rust-driver#1226), the `IndexModel` builder now builds the default index name differently (the previous behavior was incorrect, and those quotes should not have been present there). This only affects the `IndexModel::builder()` API which we exclusively use in our introspection tests. There's no change in behavior for end users. `cruet` change needs to be reverted because it has different behavior compared to `convert_case` in the presence of consecutive capital letters, which leads to actual regressions in tests related to composite types. /test-all
1 parent 00f1b68 commit a2b481b

5 files changed

Lines changed: 28 additions & 18 deletions

File tree

Cargo.lock

Lines changed: 10 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ chrono = "0.4"
6464
colored = "3"
6565
concat-idents = "1"
6666
connection-string = "0.2"
67+
convert_case = "0.8"
6768
crossbeam-channel = "0.5"
6869
cruet = "0.15"
6970
cuid = { git = "https://github.com/prisma/cuid-rust", branch = "v1.3.3-wasm32-unknown-unknown" }

schema-engine/connectors/mongodb-schema-connector/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ bson.workspace = true
2020
serde_json.workspace = true
2121
tokio.workspace = true
2222
tracing.workspace = true
23-
cruet.workspace = true
23+
convert_case.workspace = true
2424
regex.workspace = true
2525
indoc.workspace = true
2626

schema-engine/connectors/mongodb-schema-connector/src/sampler/statistics.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use schema_connector::{
1313

1414
use super::field_type::FieldType;
1515
use bson::{Bson, Document};
16-
use cruet::Inflector;
16+
use convert_case::{Case, Casing};
1717
use datamodel_renderer as renderer;
1818
use mongodb_schema_describer::{CollectionWalker, IndexWalker};
1919
use psl::datamodel_connector::constraint_names::ConstraintNames;
@@ -63,7 +63,7 @@ impl<'a> Statistics<'a> {
6363
fn composite_type_name(&self, model: &str, field: &str) -> Name {
6464
let combined: String = format!("{model}_{field}").chars().filter(|c| c.is_ascii()).collect();
6565

66-
let name = Name::Model(combined.to_pascal_case());
66+
let name = Name::Model(combined.to_case(Case::Pascal));
6767

6868
let name = if self.models.contains_key(&name) {
6969
format!("{name}_")
@@ -521,7 +521,7 @@ impl<'a> Statistics<'a> {
521521
(name, field.clone())
522522
};
523523

524-
let type_name = format!("{container_name}_{field}").to_pascal_case();
524+
let type_name = format!("{container_name}_{field}").to_case(Case::Pascal);
525525
let type_name = sanitize_string(&type_name).unwrap_or(type_name);
526526
container_name.clone_from(&type_name);
527527

schema-engine/connectors/mongodb-schema-connector/tests/introspection/index/mod.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ fn single_column_fulltext_index() {
257257
age Int
258258
name String
259259
260-
@@fulltext([name], map: "name_\"text\"")
260+
@@fulltext([name], map: "name_text")
261261
}
262262
"#]];
263263

@@ -295,7 +295,7 @@ fn single_column_fulltext_composite_index() {
295295
address CatAddress
296296
name String
297297
298-
@@fulltext([address.street], map: "address.street_\"text\"")
298+
@@fulltext([address.street], map: "address.street_text")
299299
}
300300
"#]];
301301

@@ -334,7 +334,7 @@ fn single_array_column_fulltext_composite_index() {
334334
addresses CatAddresses[]
335335
name String
336336
337-
@@fulltext([addresses.street], map: "addresses.street_\"text\"")
337+
@@fulltext([addresses.street], map: "addresses.street_text")
338338
}
339339
"#]];
340340

@@ -369,7 +369,7 @@ fn multi_column_fulltext_index() {
369369
name String
370370
title String
371371
372-
@@fulltext([name, title], map: "name_\"text\"_title_\"text\"")
372+
@@fulltext([name, title], map: "name_text_title_text")
373373
}
374374
"#]];
375375

@@ -408,7 +408,7 @@ fn multi_column_fulltext_composite_index() {
408408
address CatAddress
409409
name String
410410
411-
@@fulltext([address.city, address.street], map: "address.street_\"text\"_address.city_\"text\"")
411+
@@fulltext([address.city, address.street], map: "address.street_text_address.city_text")
412412
}
413413
"#]];
414414

@@ -443,7 +443,7 @@ fn multi_column_fulltext_index_with_desc_in_end() {
443443
name String
444444
title String
445445
446-
@@fulltext([name, title, age(sort: Desc)], map: "name_\"text\"_title_\"text\"_age_-1")
446+
@@fulltext([name, title, age(sort: Desc)], map: "name_text_title_text_age_-1")
447447
}
448448
"#]];
449449

@@ -482,7 +482,7 @@ fn multi_column_fulltext_composite_index_with_desc_in_end() {
482482
address CatAddress
483483
name String
484484
485-
@@fulltext([address.street, name, address.number(sort: Desc)], map: "name_\"text\"_address.street_\"text\"_address.number_-1")
485+
@@fulltext([address.street, name, address.number(sort: Desc)], map: "name_text_address.street_text_address.number_-1")
486486
}
487487
"#]];
488488

@@ -517,7 +517,7 @@ fn multi_column_fulltext_index_with_desc_in_beginning() {
517517
name String
518518
title String
519519
520-
@@fulltext([age(sort: Desc), name, title], map: "age_-1_name_\"text\"_title_\"text\"")
520+
@@fulltext([age(sort: Desc), name, title], map: "age_-1_name_text_title_text")
521521
}
522522
"#]];
523523

@@ -556,7 +556,7 @@ fn multi_column_fulltext_composite_index_with_desc_in_beginning() {
556556
address CatAddress
557557
name String
558558
559-
@@fulltext([address.number(sort: Desc), address.street, name], map: "address.number_-1_address.street_\"text\"_name_\"text\"")
559+
@@fulltext([address.number(sort: Desc), address.street, name], map: "address.number_-1_address.street_text_name_text")
560560
}
561561
"#]];
562562

@@ -591,7 +591,7 @@ fn multi_column_fulltext_index_with_asc_in_end() {
591591
name String
592592
title String
593593
594-
@@fulltext([name, title, age(sort: Asc)], map: "name_\"text\"_title_\"text\"_age_1")
594+
@@fulltext([name, title, age(sort: Asc)], map: "name_text_title_text_age_1")
595595
}
596596
"#]];
597597

@@ -626,7 +626,7 @@ fn multi_column_fulltext_index_with_asc_in_beginning() {
626626
name String
627627
title String
628628
629-
@@fulltext([age(sort: Asc), name, title], map: "age_1_name_\"text\"_title_\"text\"")
629+
@@fulltext([age(sort: Asc), name, title], map: "age_1_name_text_title_text")
630630
}
631631
"#]];
632632

@@ -702,7 +702,7 @@ fn fultext_index() {
702702
age Int
703703
name String
704704
705-
@@fulltext([name], map: "name_\"text\"")
705+
@@fulltext([name], map: "name_text")
706706
}
707707
"#]];
708708

@@ -742,7 +742,7 @@ fn fultext_composite_index() {
742742
address CatAddress
743743
name String
744744
745-
@@fulltext([address.street], map: "address.street_\"text\"")
745+
@@fulltext([address.street], map: "address.street_text")
746746
}
747747
"#]];
748748

0 commit comments

Comments
 (0)