-
Notifications
You must be signed in to change notification settings - Fork 213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(schema-engine): Ignore views for MongoDB Schemas #4167
fix(schema-engine): Ignore views for MongoDB Schemas #4167
Conversation
Related to #18424 and #17006 issues at /prisma/prisma repo.
CodSpeed Performance ReportMerging #4167 will not alter performanceComparing Summary
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Blocking this because I tried it and while the error message is gone it brings unexpected changes
I ran PRISMA_SCHEMA_ENGINE_BINARY=/Users/j42/Dev/prisma-engines/target/debug/schema-engine npx prisma db pull --force
which ran successfully.
Though check the output
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "mongodb"
url = "mongodb://root:prisma@localhost:27018/hey?authSource=admin"
}
type System.viewsPipeline {
lookup System.viewsPipeline$lookup? @map("$lookup")
project System.viewsPipeline$project? @map("$project")
unwind String? @map("$unwind")
}
type System.viewsPipeline$lookup {
as String
foreignField String
from String
localField String
}
type System.viewsPipeline$project {
id Int @map("_id")
bio String
email Int
name Int
}
model Plan {
id String @id @default(auto()) @map("_id") @db.ObjectId
}
model ho {
id String @id @default(auto()) @map("_id") @db.ObjectId
}
model system_views {
id String @id @map("_id")
pipeline System.viewsPipeline[]
viewOn String
@@map("system.views")
}
The type System.*
are unexpected (and also not valid syntax, no period is allowed in the name).
So it looks like some logic needs to be adapted to ignore introspecting the system
collection itself?
I first ran
(where It returned [
{
name: 'myModel',
type: 'collection',
options: {},
info: {
readOnly: false,
uuid: new UUID("2c070c30-bdf1-4f9d-abfd-5120d56132a0")
},
idIndex: { v: 2, key: [Object], name: '_id_' }
},
{
name: 'system.views',
type: 'collection',
options: {},
info: {
readOnly: false,
uuid: new UUID("d3d65bdb-d7e1-42a4-9083-b605926b321d")
},
idIndex: { v: 2, key: [Object], name: '_id_' }
},
{
name: 'UserInfo',
type: 'view',
options: { viewOn: 'User', pipeline: [Array] },
info: { readOnly: true }
}
] Based on the docs, it makes sense that the
|
I pushed a fix. I'll ask a colleague about how we want to test this. |
Note: I verified that the test was not working before and showed the same issues before the fix. |
I'm not sure why Clippy errors on unrelated files? |
That's that clippy usually does 😄 |
Rust 1.72 was released yesterday so probably was now updated on CI. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fixes and test look good 💯
// We need to skip system collections, they are only used by MongoDB internally. | ||
// https://www.mongodb.com/docs/manual/reference/system-collections/ | ||
if collection_type == mongodb::results::CollectionType::Collection && collection_name.starts_with("system.") { | ||
continue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do these show up because we have a view? That's a bit mysterious.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, when there is a view inside the database MongoDB stores some information inside that same database as a system.views
(invisible in GUI) collection
I'll wait for the clippy PR to be merged before merging this |
Note: this is now available in |
Related to #18424 and #17006 issues.
Proposed trivial approach: While iterating the collections, if we detect a View, we continue to the next collection.