Skip to content
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

[Bug]: Code hangs when using field of type array or tuple in the order by clause of a query #43418

Closed
poorna2152 opened this issue Sep 24, 2024 · 2 comments · Fixed by #43427
Closed
Assignees
Labels
Area/Compiler Lang/Expressions/Query Reason/EngineeringMistake The issue occurred due to a mistake made in the past. Type/Bug
Milestone

Comments

@poorna2152
Copy link
Contributor

Description

Consider the following code,

import ballerina/io;
import ballerina/time;

type A record {|
    time:Utc t;
    int i;
    string s;
|};

public function main() returns error? {
    A[] lotOfA = [
        {i: 1, s: "s1", t: check time:utcFromString("2007-12-03T10:15:30.00Z")},
        {i: 1, s: "s1", t: check time:utcFromString("2008-12-03T10:15:30.00Z")},
        {i: 1, s: "s1", t: check time:utcFromString("2004-12-03T10:15:30.00Z")},
        {i: 1, s: "s1", t: check time:utcFromString("2012-12-03T10:15:30.00Z")}
    ];

    string[] lotOfS = from A a in lotOfA
        where a.i == 1
        order by a.t descending
        select a.s;
    io:println(lotOfS);
}

Following code hangs when running. This should not throw an compiler error because it should be possible to use a field of type time:Utc to order.

Steps to Reproduce

No response

Affected Version(s)

No response

OS, DB, other environment details and versions

No response

Related area

-> Compilation

Related issue(s) (optional)

No response

Suggested label(s) (optional)

No response

Suggested assignee(s) (optional)

No response

@ballerina-bot ballerina-bot added needTriage The issue has to be inspected and labeled manually userCategory/Compilation labels Sep 24, 2024
@poorna2152 poorna2152 added Lang/Expressions/Query and removed needTriage The issue has to be inspected and labeled manually userCategory/Compilation labels Sep 24, 2024
@poorna2152
Copy link
Contributor Author

poorna2152 commented Sep 24, 2024

The issue lies in using a array type as the order-key in the order clause. This is reproducible with the following code.

import ballerina/io;

type A record {|
    [int] t;
    int i;
    string s;
|};

public function main() returns error? {
    A[] lotOfA = [
        {i: 1, s: "s1", t: [5]},
        {i: 1, s: "s1", t: [1]},
        {i: 1, s: "s1", t: [0]},
        {i: 1, s: "s1", t: [4]}
    ];

    string[] lotOfS = from A a in lotOfA
        where a.i == 1
        order by a.t descending
        select a.s;
    io:println(lotOfS);
}

@poorna2152 poorna2152 changed the title [Bug]: Code hangs when using field of type time:Utc in the order by clause of a query [Bug]: Code hangs when using field of type array or tuple in the order by clause of a query Sep 26, 2024
@poorna2152 poorna2152 self-assigned this Sep 26, 2024
Copy link

github-actions bot commented Oct 2, 2024

This issue is NOT closed with a proper Reason/ label. Make sure to add proper reason label before closing. Please add or leave a comment with the proper reason label now.

      - Reason/EngineeringMistake - The issue occurred due to a mistake made in the past.
      - Reason/Regression - The issue has introduced a regression.
      - Reason/MultipleComponentInteraction - Issue occured due to interactions in multiple components.
      - Reason/Complex - Issue occurred due to complex scenario.
      - Reason/Invalid - Issue is invalid.
      - Reason/Other - None of the above cases.

@gimantha gimantha added the Reason/EngineeringMistake The issue occurred due to a mistake made in the past. label Oct 2, 2024
@AzeemMuzammil AzeemMuzammil added this to the 2201.10.2 milestone Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area/Compiler Lang/Expressions/Query Reason/EngineeringMistake The issue occurred due to a mistake made in the past. Type/Bug
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

4 participants