Skip to content

Commit

Permalink
Add nested query with onConflict error test
Browse files Browse the repository at this point in the history
  • Loading branch information
LakshanWeerasinghe committed Mar 21, 2024
1 parent c415c47 commit a7e115e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,11 @@ public void testTableConstructQueryWithConflictingKeys() {
BRunUtil.invoke(result, "testTableConstructQueryWithConflictingKeys");
}

@Test(description = "Test table creating nested query with conflicting keys and onConflict error")
public void testMapConstructNestedQueryWithConflictingKeys() {
BRunUtil.invoke(result, "testMapConstructNestedQueryWithConflictingKeys");
}

@Test(description = "Test negative scenarios for query expr with query construct type")
public void testNegativeScenarios() {
int index = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1904,6 +1904,23 @@ function getQueryResult(error onConflictError, Customer[] customerList) returns
on conflict onConflictError;
}

function testMapConstructNestedQueryWithConflictingKeys() {
Customer c1 = {id: 1, name: "Melina", noOfItems: 12};
Customer c2 = {id: 2, name: "James", noOfItems: 5};
Customer c3 = {id: 3, name: "Anne", noOfItems: 20};
Customer[] customerList = [c1, c2, c3, c1];
(anydata|error)[] result = from var i in [1]
select table key(id, name) from var customer in customerList
select {
id: customer.id,
name: customer.name,
noOfItems: customer.noOfItems
}
on conflict error(string `Error key: ${customer.id} iteration: ${i}`);
assertEqual(result[0] is error, true);
assertEqual((<error>result[0]).message(), "Error key: 1 iteration: 1");
}

function assertEqual(anydata|error actual, anydata|error expected) {
anydata expectedValue = (expected is error)? (<error> expected).message() : expected;
anydata actualValue = (actual is error)? (<error> actual).message() : actual;
Expand Down

0 comments on commit a7e115e

Please sign in to comment.