Skip to content

Commit

Permalink
Include an enum for ordering
Browse files Browse the repository at this point in the history
  • Loading branch information
poorna2152 committed Oct 1, 2024
1 parent 98f9997 commit 35407ff
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,12 @@ function incrementCount(int i) returns int {
return count;
}

enum Color {
RED,
GREEN,
BLUE
}

function testQueryExprWithOrderByClauseWithArrayKey() {
record {|int[] t; string s;|}[] data1 = [
{s: "s5", t: [5, 2]},
Expand Down Expand Up @@ -590,6 +596,19 @@ function testQueryExprWithOrderByClauseWithArrayKey() {
order by rec.arr1 descending
select rec.k;
assertEquality([4, 5, 1, 2, 3], q7);

record {|int k; Color[] arr1;|}[] data8 = [
{k: 1, arr1: [RED]},
{k: 2, arr1: [RED, GREEN]},
{k: 3, arr1: [GREEN, BLUE, RED]},
{k: 4, arr1: [BLUE, RED]},
{k: 5, arr1: [BLUE, BLUE]}
];

int[] q8 = from var rec in data8
order by rec.arr1 descending
select rec.k;
assertEquality([2, 1, 3, 4, 5], q8);
}

function assertEquality(anydata expected, anydata actual) {
Expand Down

0 comments on commit 35407ff

Please sign in to comment.