-
-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: new
break
statement in scripts to exit from a loop/foreach
Fixed issue #1647
- Loading branch information
Showing
12 changed files
with
4,886 additions
and
4,663 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
engine/src/main/java/com/arcadedb/query/sql/executor/BreakStep.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright © 2021-present Arcade Data Ltd (info@arcadedata.com) | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* SPDX-FileCopyrightText: 2021-present Arcade Data Ltd (info@arcadedata.com) | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
package com.arcadedb.query.sql.executor; | ||
|
||
import com.arcadedb.exception.TimeoutException; | ||
import com.arcadedb.query.sql.parser.BreakStatement; | ||
import com.arcadedb.query.sql.parser.SimpleExecStatement; | ||
|
||
/** | ||
* @author Luca Garulli (l.garulli@arcadedata.com) | ||
*/ | ||
public class BreakStep extends AbstractExecutionStep { | ||
public BreakStep(final CommandContext context) { | ||
super(context); | ||
} | ||
|
||
@Override | ||
public ResultSet syncPull(final CommandContext context, final int nRecords) throws TimeoutException { | ||
return BreakStatement.BREAK_RESULTSET; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
engine/src/main/java/com/arcadedb/query/sql/parser/BreakStatement.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* Generated By:JJTree: Do not edit this line. BreakStatement.java Version 7.0 */ | ||
/* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=false,TRACK_TOKENS=true,NODE_PREFIX=,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ | ||
package com.arcadedb.query.sql.parser; | ||
|
||
import com.arcadedb.query.sql.executor.CommandContext; | ||
import com.arcadedb.query.sql.executor.InternalResultSet; | ||
import com.arcadedb.query.sql.executor.Result; | ||
import com.arcadedb.query.sql.executor.ResultSet; | ||
|
||
import java.util.*; | ||
|
||
public class BreakStatement extends SimpleExecStatement { | ||
public static final ResultSet BREAK_RESULTSET = new ResultSet() { | ||
@Override | ||
public boolean hasNext() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public Result next() { | ||
return null; | ||
} | ||
}; | ||
|
||
public BreakStatement(int id) { | ||
super(id); | ||
} | ||
|
||
@Override | ||
public ResultSet executeSimple(final CommandContext context) { | ||
return BREAK_RESULTSET; | ||
} | ||
|
||
@Override | ||
public void toString(final Map<String, Object> params, final StringBuilder builder) { | ||
builder.append("RETURN"); | ||
} | ||
} | ||
/* JavaCC - OriginalChecksum=7c151cab41b31cd675cea2f3becdc628 (do not edit this line) */ |
Oops, something went wrong.