-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Failure to parse query with PRIOR in select list (#2083)
* Added support for PRIOR operator to be used in select list * Fixed copy paste issue
- Loading branch information
Showing
11 changed files
with
155 additions
and
0 deletions.
There are no files selected for viewing
63 changes: 63 additions & 0 deletions
63
src/main/java/net/sf/jsqlparser/expression/ConnectByPriorOperator.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,63 @@ | ||
/*- | ||
* #%L | ||
* JSQLParser library | ||
* %% | ||
* Copyright (C) 2004 - 2021 JSQLParser | ||
* %% | ||
* Dual licensed under GNU LGPL 2.1 or Apache License 2.0 | ||
* #L% | ||
*/ | ||
/* | ||
* Copyright (C) 2021 JSQLParser. | ||
* | ||
* This library is free software; you can redistribute it and/or modify it under the terms of the | ||
* GNU Lesser General Public License as published by the Free Software Foundation; either version | ||
* 2.1 of the License, or (at your option) any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without | ||
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License along with this library; | ||
* if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
* 02110-1301 USA | ||
*/ | ||
|
||
package net.sf.jsqlparser.expression; | ||
|
||
import net.sf.jsqlparser.parser.ASTNodeAccessImpl; | ||
import net.sf.jsqlparser.schema.Column; | ||
|
||
import java.util.Objects; | ||
|
||
/** | ||
* | ||
* @author are | ||
*/ | ||
public class ConnectByPriorOperator extends ASTNodeAccessImpl implements Expression { | ||
private final Column column; | ||
|
||
public ConnectByPriorOperator(Column column) { | ||
this.column = Objects.requireNonNull(column, | ||
"The COLUMN of the ConnectByPrior Operator must not be null"); | ||
} | ||
|
||
public Column getColumn() { | ||
return column; | ||
} | ||
|
||
@Override | ||
public <T, S> T accept(ExpressionVisitor<T> expressionVisitor, S context) { | ||
return expressionVisitor.visit(this, context); | ||
} | ||
|
||
public StringBuilder appendTo(StringBuilder builder) { | ||
builder.append("PRIOR ").append(column); | ||
return builder; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return appendTo(new StringBuilder()).toString(); | ||
} | ||
} |
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
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
15 changes: 15 additions & 0 deletions
15
src/test/resources/net/sf/jsqlparser/statement/select/oracle-tests/connect_by08.sql
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,15 @@ | ||
--- | ||
-- #%L | ||
-- JSQLParser library | ||
-- %% | ||
-- Copyright (C) 2004 - 2019 JSQLParser | ||
-- %% | ||
-- Dual licensed under GNU LGPL 2.1 or Apache License 2.0 | ||
-- #L% | ||
--- | ||
select t.*, connect_by_root t.id as root_id | ||
from test t | ||
start with t.id = 1 | ||
connect by prior t.id = t.parent_id | ||
order siblings by t.some_text | ||
--@SUCCESSFULLY_PARSED_AND_DEPARSED first on Oct 2, 2024, 8:11:58 PM |
15 changes: 15 additions & 0 deletions
15
src/test/resources/net/sf/jsqlparser/statement/select/oracle-tests/connect_by09.sql
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,15 @@ | ||
--- | ||
-- #%L | ||
-- JSQLParser library | ||
-- %% | ||
-- Copyright (C) 2004 - 2019 JSQLParser | ||
-- %% | ||
-- Dual licensed under GNU LGPL 2.1 or Apache License 2.0 | ||
-- #L% | ||
--- | ||
select t.*, prior t.id parent_id | ||
from test t | ||
start with t.id = 1 | ||
connect by prior t.id = t.parent_id | ||
order siblings by t.some_text | ||
--@SUCCESSFULLY_PARSED_AND_DEPARSED first on Oct 2, 2024, 8:14:31 PM |
15 changes: 15 additions & 0 deletions
15
src/test/resources/net/sf/jsqlparser/statement/select/oracle-tests/connect_by10.sql
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,15 @@ | ||
--- | ||
-- #%L | ||
-- JSQLParser library | ||
-- %% | ||
-- Copyright (C) 2004 - 2019 JSQLParser | ||
-- %% | ||
-- Dual licensed under GNU LGPL 2.1 or Apache License 2.0 | ||
-- #L% | ||
--- | ||
select t.*, prior t.id as parent_id | ||
from test t | ||
start with t.id = 1 | ||
connect by prior t.id = t.parent_id | ||
order siblings by t.some_text | ||
--@SUCCESSFULLY_PARSED_AND_DEPARSED first on Oct 2, 2024, 8:14:33 PM |