Skip to content

Commit

Permalink
qe: filter out unique criteria containing an unsupported field
Browse files Browse the repository at this point in the history
They are not usable by the query engine, and currently cause crashes
whenever querying the model containing them.

closes prisma/prisma#18517
  • Loading branch information
tomhoule committed May 8, 2023
1 parent bd111df commit ad689bc
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 5 deletions.
1 change: 1 addition & 0 deletions psl/parser-database/src/walkers/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ impl<'db> ModelWalker<'db> {
db,
index_attribute,
})
.filter(|index| !index.fields().any(|f| f.is_unsupported()))
}

/// All (concrete) relation fields of the model.
Expand Down
9 changes: 5 additions & 4 deletions query-engine/connector-test-kit-rs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ The test kit is a (currently incomplete) port of the Scala test kit, located in
It's fully focused on integration testing the query engine through request-response assertions.

## Test organization
The test kit is a combination of three crates, from which two are "lower level" crates that are only required to make it work, whereas only one is important if you only want to author tests. The three-crate approach is required to prevent circular dependencies between the crates (arrow = depends-on):

The test kit is a combination of three crates, from which two are "lower level" crates that are only required to make it work, whereas only one is important if you only want to author tests.
```
┌────────────────────┐
┌───│ query-engine-tests │───┐
└────────────────────┘ │
│ query-engine-tests │───┐
└────────────────────┘ │
┌────────────────────┐ ┌────────────────────┐
│ query-test-macros │──────▶│ query-tests-setup │
└────────────────────┘ └────────────────────┘
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ mod prisma_15581;
mod prisma_15607;
mod prisma_16760;
mod prisma_17103;
mod prisma_18517;
mod prisma_5952;
mod prisma_6173;
mod prisma_7010;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use indoc::indoc;
use query_engine_tests::*;

#[test_suite(schema(schema))]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
use query_engine_tests::*;

#[test_suite(schema(schema), only(Postgres))]
mod prisma_18517 {
fn schema() -> String {
r#"
model Container {
id String @id @default(uuid()) @test.Char(20)
createdAt DateTime @default(now())
label String?
parent Container? @relation("ContainerToContainer", fields: [parentId], references: [id], onDelete: Cascade)
parentId String? @test.Char(20)
path Unsupported("money")? @unique
childContainers Container[] @relation("ContainerToContainer")
}
"#.to_owned()
}

#[connector_test]
async fn regression(runner: Runner) -> TestResult<()> {
run_query! {
&runner,
r#"query { findManyContainer(where: { label: "root", parentId: null }) { id }}"#
};
Ok(())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ impl ModelProjection {
self.fields
.iter()
.flat_map(|field| match field {
Field::Scalar(sf) if matches!(sf.type_identifier(), TypeIdentifier::Unsupported) => Vec::new(),
Field::Scalar(sf) => vec![sf.clone()],
Field::Relation(rf) => rf.scalar_fields(),
Field::Composite(_) => todo!(), // [Composites] todo
Expand Down

0 comments on commit ad689bc

Please sign in to comment.