-
Notifications
You must be signed in to change notification settings - Fork 218
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(schema-engine): Ignore views for MongoDB Schemas (#4167)
Co-authored-by: Joël Galeran <Jolg42@users.noreply.github.com> Co-authored-by: Jan Piotrowski <piotrowski+github@gmail.com>
- Loading branch information
1 parent
f957933
commit d7eca61
Showing
3 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ mod index; | |
mod model_renames; | ||
mod remapping_names; | ||
mod types; | ||
mod views; |
38 changes: 38 additions & 0 deletions
38
schema-engine/connectors/mongodb-schema-connector/tests/introspection/views/mod.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
use crate::introspection::test_api::*; | ||
use mongodb::{bson::doc, options::CreateCollectionOptions}; | ||
|
||
#[test] | ||
fn collection_with_view() { | ||
let res = introspect(|db| async move { | ||
db.create_collection("A", None).await?; | ||
db.create_collection( | ||
"myView".to_string(), | ||
Some( | ||
CreateCollectionOptions::builder() | ||
.view_on("A".to_string()) | ||
.pipeline(vec![doc! { | ||
"$lookup": { | ||
"from": "A", | ||
"localField": "first", | ||
"foreignField": "_id", | ||
"as": "someid" | ||
}, | ||
}]) | ||
.build(), | ||
), | ||
) | ||
.await?; | ||
|
||
Ok(()) | ||
}); | ||
|
||
let expected_warning = expect![""]; | ||
res.expect_warnings(&expected_warning); | ||
|
||
let expected_doc = expect![[r#" | ||
model A { | ||
id String @id @default(auto()) @map("_id") @db.ObjectId | ||
} | ||
"#]]; | ||
expected_doc.assert_eq(res.datamodel()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters