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

SQL Script: BREAK is ignored when followed by other statements #1672

Closed
finduspedersen opened this issue Jul 25, 2024 · 2 comments
Closed

SQL Script: BREAK is ignored when followed by other statements #1672

finduspedersen opened this issue Jul 25, 2024 · 2 comments
Assignees
Labels
bug Something isn't working fixed
Milestone

Comments

@finduspedersen
Copy link

ArcadeDB Version:

24.6.1

OS and JDK Version:

Official Docker image

Expected behavior

Should immediately terminate the FOREACH loop when reaching the BREAK statement

Actual behavior

The execution continues, and BREAK is ignored as seen in this console output:

2024-07-25 16:10:05 2024-07-25 14:10:05.721 INFO [ConsoleStatement] <ArcadeDB_0> {DEBUG=Element=1}
2024-07-25 16:10:05 2024-07-25 14:10:05.721 INFO [ConsoleStatement] <ArcadeDB_0> {DEBUG=After IF}
2024-07-25 16:10:05 2024-07-25 14:10:05.721 INFO [ConsoleStatement] <ArcadeDB_0> {DEBUG=Element=2}
2024-07-25 16:10:05 2024-07-25 14:10:05.721 INFO [ConsoleStatement] <ArcadeDB_0> {DEBUG=Hello World}
2024-07-25 16:10:05 2024-07-25 14:10:05.721 INFO [ConsoleStatement] <ArcadeDB_0> {REMOVE=This should never be reached}
2024-07-25 16:10:05 2024-07-25 14:10:05.721 INFO [ConsoleStatement] <ArcadeDB_0> {DEBUG=After IF}
2024-07-25 16:10:05 2024-07-25 14:10:05.721 INFO [ConsoleStatement] <ArcadeDB_0> {DEBUG=Element=3}
2024-07-25 16:10:05 2024-07-25 14:10:05.721 INFO [ConsoleStatement] <ArcadeDB_0> {DEBUG=After IF}
2024-07-25 16:10:05 2024-07-25 14:10:05.721 INFO [ConsoleStatement] <ArcadeDB_0> {DEBUG=END}

Steps to reproduce

If the CONSOLE.log following the BREAK statement is removed, then the BREAK statement is executed as expected and the FOREACH loop is terminated.

LET $list = [1, 2, 3];

FOREACH ($element IN $list) {
CONSOLE.log map('DEBUG', 'Element=' + $element.asString());

IF ($element = 2) {
CONSOLE.log map('DEBUG', 'Hello World');
BREAK;
CONSOLE.log map('REMOVE', 'This should never be reached');
}

CONSOLE.log map('DEBUG', 'After IF');
}

CONSOLE.log map('DEBUG', 'END');

@lvca lvca self-assigned this Jul 28, 2024
@lvca lvca added the bug Something isn't working label Jul 28, 2024
@lvca lvca added this to the 24.8.1 milestone Jul 28, 2024
@lvca
Copy link
Contributor

lvca commented Jul 28, 2024

This is the same issue as #1673. The break doesn't really break in some cases. Working on a fix.

lvca added a commit that referenced this issue Jul 28, 2024
@lvca
Copy link
Contributor

lvca commented Jul 28, 2024

Fixed.

@lvca lvca closed this as completed Jul 28, 2024
@lvca lvca added the fixed label Jul 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed
Projects
None yet
Development

No branches or pull requests

2 participants