Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Weakky committed Oct 25, 2022
1 parent be5d99a commit eaaec29
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ mod regression {
.assert_success();

let queries = vec![
r#"query {findUniqueArtist(where:{firstName_lastName_birth:{firstName:"Michael",netWorth:"236600000.12409"}}) {firstName netWorth}}"#.to_string(),
r#"query {findUniqueArtist(where:{firstName_lastName_birth:{firstName:"George",netWorth:"-0.23660010012409"}}) {firstName netWorth}}"#.to_string(),
r#"query {findUniqueArtist(where:{firstName_netWorth:{firstName:"Michael",netWorth:"236600000.12409"}}) {firstName netWorth}}"#.to_string(),
r#"query {findUniqueArtist(where:{firstName_netWorth:{firstName:"George",netWorth:"-0.23660010012409"}}) {firstName netWorth}}"#.to_string(),
];

let batch_results = runner.batch(queries, false, None).await?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,17 +296,30 @@ mod compound_batch {

#[connector_test(schema(common_list_types), capabilities(ScalarLists))]
async fn should_only_batch_if_possible_list(runner: Runner) -> TestResult<()> {
// COMPACT: Queries use compound unique
let doc = compact_batch(
run_query!(
&runner,
r#"mutation { createOneTestModel(data: { id: 1, int: [1, 2, 3] }) { id } }"#
);
run_query!(
&runner,
vec![
r#"query {findUniqueTestModel(where:{ id: 1, str_list: [1, 2, 3] }) {id}}"#.to_string(),
r#"query {findUniqueTestModel(where:{ id: 2, str_list: [1, 3, 4] }}) {id}}"#.to_string(),
],
)
.await?;
r#"mutation { createOneTestModel(data: { id: 2, int: [1, 3, 4] }) { id } }"#
);

let queries = vec![
r#"query {findUniqueTestModel(where:{ id: 1, int: { equals: [1, 2, 3] } }) {id, int}}"#.to_string(),
r#"query {findUniqueTestModel(where:{ id: 2, int: { equals: [1, 3, 4] } }) {id, int}}"#.to_string(),
];

// COMPACT: Queries use scalar list
let doc = compact_batch(&runner, queries.clone()).await?;
assert!(doc.is_compact());

let batch_results = runner.batch(queries, false, None).await?;
insta::assert_snapshot!(
batch_results.to_string(),
@r###"{"batchResult":[{"data":{"findUniqueTestModel":{"id":1,"int":[1,2,3]}}},{"data":{"findUniqueTestModel":{"id":2,"int":[1,3,4]}}}]}"###
);

Ok(())
}

Expand Down
13 changes: 13 additions & 0 deletions query-engine/core/src/response_ir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,19 @@ impl Item {
match self {
Self::Value(pv) => Some(pv),
Self::Ref(r) => Arc::try_unwrap(r).ok().and_then(|r| r.into_value()),
Self::List(list) => {
let mut values = vec![];

for item in list {
if let Some(pv) = item.into_value() {
values.push(pv)
} else {
return None;
}
}

Some(PrismaValue::List(values))
}
_ => None,
}
}
Expand Down

0 comments on commit eaaec29

Please sign in to comment.