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 in nested FOREACH loop #1673

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

SQL Script: BREAK is ignored in nested FOREACH loop #1673

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

BREAK should terminate the nested FOREACH loop

Actual behavior

BREAK is ignored in nested FOREACH loop

2024-07-25 16:26:21 2024-07-25 14:26:21.064 INFO [ConsoleStatement] <ArcadeDB_0> {DEBUG=Number=1}
2024-07-25 16:26:21 2024-07-25 14:26:21.064 INFO [ConsoleStatement] <ArcadeDB_0> {DEBUG=Letter=A}
2024-07-25 16:26:21 2024-07-25 14:26:21.064 INFO [ConsoleStatement] <ArcadeDB_0> {DEBUG=### Number=1, Letter=A}
2024-07-25 16:26:21 2024-07-25 14:26:21.064 INFO [ConsoleStatement] <ArcadeDB_0> {DEBUG=Letter=B}
2024-07-25 16:26:21 2024-07-25 14:26:21.064 INFO [ConsoleStatement] <ArcadeDB_0> {DEBUG=### Number=1, Letter=B}
2024-07-25 16:26:21 2024-07-25 14:26:21.064 INFO [ConsoleStatement] <ArcadeDB_0> {DEBUG=Letter=C}
2024-07-25 16:26:21 2024-07-25 14:26:21.064 INFO [ConsoleStatement] <ArcadeDB_0> {DEBUG=### Number=1, Letter=C}
2024-07-25 16:26:21 2024-07-25 14:26:21.064 INFO [ConsoleStatement] <ArcadeDB_0> {DEBUG=Number=2}
2024-07-25 16:26:21 2024-07-25 14:26:21.064 INFO [ConsoleStatement] <ArcadeDB_0> {DEBUG=Letter=A}
2024-07-25 16:26:21 2024-07-25 14:26:21.065 INFO [ConsoleStatement] <ArcadeDB_0> {DEBUG=Hello World 1}
2024-07-25 16:26:21 2024-07-25 14:26:21.065 INFO [ConsoleStatement] <ArcadeDB_0> {DEBUG=### Number=2, Letter=A}
2024-07-25 16:26:21 2024-07-25 14:26:21.065 INFO [ConsoleStatement] <ArcadeDB_0> {DEBUG=Letter=B}
2024-07-25 16:26:21 2024-07-25 14:26:21.065 INFO [ConsoleStatement] <ArcadeDB_0> {DEBUG=Hello World 1}
2024-07-25 16:26:21 2024-07-25 14:26:21.065 INFO [ConsoleStatement] <ArcadeDB_0> {DEBUG=Hello World 2}
2024-07-25 16:26:21 2024-07-25 14:26:21.065 INFO [ConsoleStatement] <ArcadeDB_0> {DEBUG=THIS SHOULD NEVER HAPPEN!!!}
2024-07-25 16:26:21 2024-07-25 14:26:21.065 INFO [ConsoleStatement] <ArcadeDB_0> {DEBUG=### Number=2, Letter=B}
2024-07-25 16:26:21 2024-07-25 14:26:21.066 INFO [ConsoleStatement] <ArcadeDB_0> {DEBUG=Letter=C}
2024-07-25 16:26:21 2024-07-25 14:26:21.066 INFO [ConsoleStatement] <ArcadeDB_0> {DEBUG=Hello World 1}
2024-07-25 16:26:21 2024-07-25 14:26:21.066 INFO [ConsoleStatement] <ArcadeDB_0> {DEBUG=### Number=2, Letter=C}
2024-07-25 16:26:21 2024-07-25 14:26:21.066 INFO [ConsoleStatement] <ArcadeDB_0> {DEBUG=Number=3}
2024-07-25 16:26:21 2024-07-25 14:26:21.066 INFO [ConsoleStatement] <ArcadeDB_0> {DEBUG=Letter=A}
2024-07-25 16:26:21 2024-07-25 14:26:21.066 INFO [ConsoleStatement] <ArcadeDB_0> {DEBUG=### Number=3, Letter=A}
2024-07-25 16:26:21 2024-07-25 14:26:21.066 INFO [ConsoleStatement] <ArcadeDB_0> {DEBUG=Letter=B}
2024-07-25 16:26:21 2024-07-25 14:26:21.066 INFO [ConsoleStatement] <ArcadeDB_0> {DEBUG=### Number=3, Letter=B}
2024-07-25 16:26:21 2024-07-25 14:26:21.066 INFO [ConsoleStatement] <ArcadeDB_0> {DEBUG=Letter=C}
2024-07-25 16:26:21 2024-07-25 14:26:21.066 INFO [ConsoleStatement] <ArcadeDB_0> {DEBUG=### Number=3, Letter=C}
2024-07-25 16:26:21 2024-07-25 14:26:21.066 INFO [ConsoleStatement] <ArcadeDB_0> {DEBUG=END}

Steps to reproduce

LET $numbers = [1, 2, 3];
LET $letters = ['A', 'B', 'C'];

FOREACH ($number IN $numbers) {
CONSOLE.log map('DEBUG', 'Number=' + $number.asString());

FOREACH ($letter IN $letters) {
CONSOLE.log map('DEBUG', 'Letter=' + $letter);

IF ($number = 2) {
  CONSOLE.log map('DEBUG', 'Hello World 1');
  
  IF ($letter = 'B') {
  	  CONSOLE.log map('DEBUG', 'Hello World 2');
      BREAK;
  }
  
  IF ($letter = 'B') {
  	  CONSOLE.log map('DEBUG', 'THIS SHOULD NEVER HAPPEN!!!');
  }
}

CONSOLE.log map('DEBUG', '### Number=' + $number.asString() + ', Letter=' + $letter);

}
}

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 #1672. The break doesn't really break in some cases. Working on a fix.

@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