Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
123 commits
Select commit Hold shift + click to select a range
747152a
Fixes #1684: Support CREATE MATERIALIZED VIEW with AUTO REFRESH
zaza Dec 11, 2022
9e09005
Merge branch 'master' into 1684-create-mv-auto-refresh
zaza Dec 22, 2022
ea4477b
Reduce cyclomatic complexity in CreateView.toString
zaza Jan 8, 2023
b5321d6
Enhanced Keywords
manticore-projects Oct 18, 2021
5fae2f5
Fix incorrect tests
manticore-projects Oct 18, 2021
f49e828
Define Reserved Keywords explicitly
manticore-projects Oct 24, 2021
86f337d
Fix test resources
manticore-projects Oct 24, 2021
2d51a82
Adjust Gradle to JUnit 5
manticore-projects Nov 22, 2021
232aff6
Do not mark SpeedTest for concurrent execution
manticore-projects Nov 24, 2021
3ba5410
Remove unused imports
manticore-projects Nov 28, 2021
e960a35
Adjust Gradle to JUnit 5
manticore-projects Nov 22, 2021
67f7951
Do not mark SpeedTest for concurrent execution
manticore-projects Nov 24, 2021
a016be0
Remove unused imports
manticore-projects Nov 28, 2021
2ef6637
Sphinx Documentation
manticore-projects Sep 2, 2022
57193b8
doc: request for `Conventional Commit` messages
manticore-projects Sep 6, 2022
b94b2cc
feat: make important Classes Serializable
manticore-projects Sep 15, 2022
02202c5
chore: Make Serializable
manticore-projects Oct 14, 2022
a3ca325
doc: Better integration of the RR diagrams
manticore-projects Jan 7, 2023
fcb5ab1
Merge
manticore-projects Jan 7, 2023
c57c427
feat: Oracle Alternative Quoting
manticore-projects Jan 29, 2023
2aec1f6
style: Appease PMD/Codacy
manticore-projects Jan 29, 2023
1c8d8da
feat: CREATE VIEW ... REFRESH AUTO...
manticore-projects Jan 30, 2023
b707b23
doc: fix the issue template
manticore-projects Feb 1, 2023
46314c4
Update issue templates
manticore-projects Feb 1, 2023
4aeafbc
Update issue templates
manticore-projects Feb 1, 2023
b081484
feat: Support more Statement Separators
manticore-projects Feb 2, 2023
5885e1c
Merge remote-tracking branch 'origin/master'
manticore-projects Feb 13, 2023
581d97a
Merge branch 'master' of https://github.com/JSQLParser/JSqlParser
manticore-projects Feb 24, 2023
0979b2e
feat: FETCH uses EXPRESSION
manticore-projects Mar 7, 2023
ed17f87
style: apply Spotless
manticore-projects Mar 7, 2023
96808d2
test: commit missing test
manticore-projects Mar 7, 2023
21c4550
Merge branch 'master' of https://github.com/JSQLParser/JSqlParser
manticore-projects Mar 12, 2023
e8a29de
Merge branch 'master' of https://github.com/JSQLParser/JSqlParser
manticore-projects Apr 29, 2023
8a1bdec
feat: Lateral View
manticore-projects Apr 29, 2023
4efb99f
feat: Oracle `HAVING` before `GROUP BY`
manticore-projects Apr 29, 2023
9da7a06
feat: Multi-Part Names for Variables and Parameters
manticore-projects Apr 29, 2023
4b7f21c
feat: ClickHouse `Select...` ``FINAL` modifier
manticore-projects Apr 29, 2023
6281b07
feat: Test if a JOIN is an INNER JOIN according to the SQL:2016
manticore-projects Apr 30, 2023
b6ea8b1
feat: Switch off contradicting `JOIN` qualifiers, when setting a qual…
manticore-projects Apr 30, 2023
3a27a9d
feat: implement SQL:2016 Convert() and Trim()
manticore-projects Apr 30, 2023
4d5e26d
feat: ClickHouse `LIMIT ... BY ...` clause
manticore-projects Apr 30, 2023
f0a6f37
test: add specific tests for closed issues
manticore-projects Apr 30, 2023
ff16faf
test: add specific tests for closed issues
manticore-projects Apr 30, 2023
b9057d2
refactor: remove `SelectExpressionItem` in favor of `SelectItem`
manticore-projects Apr 30, 2023
286834d
doc: Update examples
manticore-projects Apr 30, 2023
0be65a4
build: Add missing import
manticore-projects Apr 30, 2023
4ddc835
doc: Update the README.md
manticore-projects May 1, 2023
fc577ca
fix: assign Enum case insensitive
manticore-projects May 2, 2023
86d0ace
fix: assign Enum case insensitive
manticore-projects May 2, 2023
a5140c7
Revert "fix: assign Enum case insensitive"
manticore-projects May 2, 2023
288b177
feat: Consolidate the `ExpressionList`, removing many redundant List …
manticore-projects May 3, 2023
905ef65
fix: Remove tests for `()`, since `ParenthesedExpressionList` will ca…
manticore-projects May 3, 2023
85b3bc4
refactor: UpdateSets for `Update` and `InsertConflictTarget`
manticore-projects May 3, 2023
e16ba5d
build: Increase TimeOut for the GitHub CI
manticore-projects May 3, 2023
2eb8c80
style: Appease Codacy
manticore-projects May 3, 2023
f449263
style: Checkstyle
manticore-projects May 3, 2023
141708e
refactor: Remove `ItemsList`, `MultiExpressionList`, `Replace`
manticore-projects May 4, 2023
67b3804
style: Appease Codacy
manticore-projects May 4, 2023
f89df27
style: Rework all the ENUMs
manticore-projects May 5, 2023
a590036
doc: Better Sphinx Tabs
manticore-projects May 6, 2023
c81d60a
doc: RR chart colors cater for Dark Mode
manticore-projects May 6, 2023
3903a80
refactor: remove SimpleFunction
manticore-projects May 6, 2023
2d200b0
build: improve Gradle Build
manticore-projects May 7, 2023
89600d4
refactor: `Insert` uses `ExpressionList` and `UpdateSet`
manticore-projects May 7, 2023
a11febb
test: Disable API Sanitation for the moment
manticore-projects May 7, 2023
399e1d7
style: Appease Checkstyle
manticore-projects May 7, 2023
f5d35d0
style: Appease PMD
manticore-projects May 7, 2023
21389b7
fix: find the correct position when field belongs to an internal class
manticore-projects May 9, 2023
52df291
style: replace all List<Expression> with ExpressionList<> and enforce…
manticore-projects May 9, 2023
9fbdaae
refactor: generify `SelectItem` and remove `FunctionItem` and `Expres…
manticore-projects May 9, 2023
7cecd29
fix: Java Version 8
manticore-projects May 9, 2023
c07a43b
feat: JdbcNamedParameter allows "&" (instead of ":")
manticore-projects May 11, 2023
09a70a4
feat: access Elements of Array Columns
manticore-projects May 11, 2023
6e7a78d
feat: `MEMBER OF` condition as shown at https://dev.mysql.com/doc/ref…
manticore-projects May 11, 2023
8a75aa7
style: appease PMD/Codacy
manticore-projects May 11, 2023
ce2b18a
style: appease PMD/Codacy
manticore-projects May 11, 2023
c9dce62
Merge remote-tracking branch 'manticore/Lateral_View' into Lateral_View
manticore-projects May 11, 2023
decf662
test: add unit test for issue #1778
manticore-projects May 11, 2023
c53667f
feat: Write API documentation to the WebSite via XMLDoclet
manticore-projects May 14, 2023
1132338
Update sphinx.yml
manticore-projects May 14, 2023
f3e8952
build: Sphinx build fixes
manticore-projects May 14, 2023
f515cda
Merge branch 'master' of https://github.com/manticore-projects/JSqlPa…
manticore-projects May 14, 2023
11b563c
build: Sphinx build fixes
manticore-projects May 14, 2023
961378d
build: Sphinx build fixes
manticore-projects May 14, 2023
48d5340
Merge branch 'master' of https://github.com/manticore-projects/JSqlPa…
manticore-projects May 14, 2023
8fb9110
build: improve the GIT Snapshot detection
manticore-projects May 15, 2023
88d1b62
fix: issue #1791
manticore-projects May 15, 2023
d20c8e9
fix: issue #1789
manticore-projects May 16, 2023
32ec561
fix: issue #1789
manticore-projects May 16, 2023
9fa0f4b
Merge remote-tracking branch 'manticore/Lateral_View' into Lateral_View
manticore-projects May 16, 2023
01a5fb7
refactor: simplify production `CreateParameter()`
manticore-projects May 16, 2023
daa56ed
refactor: SHOW statement, supporting any RDBMS specific implementation
manticore-projects May 16, 2023
4fb1cfb
refactor: RETURNING clause
manticore-projects May 16, 2023
da32442
refactor: CREATE and ALTER productions
manticore-projects May 16, 2023
4f0488c
fix: Complex Parsing Approach
manticore-projects May 17, 2023
3ff9774
style: Quieten the logger
manticore-projects May 17, 2023
a7dfb94
style: Cosmetic improvements
manticore-projects May 17, 2023
6ef5e0b
feat: chaining JSON Expressions
manticore-projects May 17, 2023
4f91746
style: remove unused imports
manticore-projects May 17, 2023
9dafae8
refact: Statements extends List<Statement>
manticore-projects May 17, 2023
4bdabed
build: try to work around the Maven/JDK8 issue on GitHub
manticore-projects May 17, 2023
64b0331
feat: parse CREATE TRIGGER as UnsupportedStatement
manticore-projects May 17, 2023
e19dc0e
feat: functions blocks, parenthesed JSON Expressions
manticore-projects May 18, 2023
5263b91
feat: functions blocks, parenthesed JSON Expressions
manticore-projects May 18, 2023
be7fc53
Create gradle.yml
manticore-projects May 18, 2023
73c55fd
feat: Quoted Identifiers can contain double-quotes (PostgreSQL)
manticore-projects May 18, 2023
a558871
build: improve Upload task
manticore-projects May 19, 2023
5e7732c
doc: Website improvements
manticore-projects May 22, 2023
68ce27c
doc: Website, fix tabs
manticore-projects May 24, 2023
cb960a3
fix: throw the specific exception
manticore-projects May 29, 2023
2b4a929
doc: write migration guide
manticore-projects May 29, 2023
54b4303
Merge branch 'master' of https://github.com/manticore-projects/JSqlPa…
manticore-projects May 29, 2023
b6fab2a
fix: expose IntervalExpression attributes and use DeParser
manticore-projects Jun 1, 2023
6d2b421
doc: migration guide
manticore-projects Jun 2, 2023
8027dbf
feat: T-SQL `FOR ...` clause
manticore-projects Jun 2, 2023
94d00f0
Merge remote-tracking branch 'origin/master'
manticore-projects Jun 2, 2023
6f27765
fix: SPHINX modules and themes
manticore-projects Jun 2, 2023
f5e9f53
docs: write migration guide
manticore-projects Jun 11, 2023
996ebd9
Merge branch 'master' of github.com:manticore-projects/JSqlParser
manticore-projects Jun 11, 2023
75e4d30
feat: `QUALIFY` clause
manticore-projects Jun 15, 2023
386dc7a
feat: Postgres `NOTNULL` support
manticore-projects Jun 15, 2023
f132547
feat: MySQL `NOT RLIKE`, `NOT REGEXP` expressions
manticore-projects Jun 15, 2023
420d7d8
fix: `INSERT` must use simple Column Names only
manticore-projects Jun 15, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: functions blocks, parenthesed JSON Expressions
- fixes #1792, the very complex example
- fixes #1477
  • Loading branch information
manticore-projects committed May 18, 2023
commit e19dc0e081f741df2c3f2a1aa909486f95c79c19
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ public static Statement parse(String sql, ExecutorService executorService,
LOGGER.info("Trying SIMPLE parsing " + (allowComplex ? "first" : "only"));
statement = parseStatement(parser.withAllowComplexParsing(false), executorService);
} catch (JSQLParserException ex) {
LOGGER.info("Nesting Depth" + getNestingDepth(sql));
if (allowComplex && getNestingDepth(sql) <= ALLOWED_NESTING_DEPTH) {
LOGGER.info("Trying COMPLEX parsing when SIMPLE parsing failed");
// beware: the parser must not be reused, but needs to be re-initiated
Expand Down
53 changes: 49 additions & 4 deletions src/main/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jjt
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ TOKEN:
input_stream.backup(image.length() - matchedToken.image.length() );
}
}
| < S_QUOTED_IDENTIFIER: "\"" (~["\n","\r","\""])* "\"" | "$$" (~["\n","\r","\""])* "$$" | ("`" (~["\n","\r","`"])+ "`") | ( "[" (~["\n","\r","]"])* "]" ) >
| < S_QUOTED_IDENTIFIER: "\"" (~["\n","\r","\""])* "\"" | "$$" (~["$"])* "$$" | ("`" (~["\n","\r","`"])+ "`") | ( "[" (~["\n","\r","]"])* "]" ) >
{
if ( !configuration.getAsBoolean(Feature.allowSquareBracketQuotation) && matchedToken.image.charAt(0) == '[' ) {
matchedToken.image = "[";
Expand Down Expand Up @@ -4048,6 +4048,17 @@ ArrayConstructor ArrayConstructor(boolean arrayKeyword) : {
{ return array; }
}

Expression ParenthesedExpression():
{
Expression expression;
}
{
"(" expression = PrimaryExpression() ")"
{
return new Parenthesis(expression);
}
}

JsonExpression JsonExpression() : {
JsonExpression result = new JsonExpression();
Expression expr;
Expand All @@ -4056,6 +4067,7 @@ JsonExpression JsonExpression() : {
CastExpression castExpr = null;
}
{
{ System.out.println("Complex:" + getAsBoolean(Feature.allowComplexParsing));}
(
LOOKAHEAD(3, {!interrupted}) expr=CaseWhenExpression()
|
Expand All @@ -4071,13 +4083,16 @@ JsonExpression JsonExpression() : {
|
LOOKAHEAD(FullTextSearch(), {getAsBoolean(Feature.allowComplexParsing) && !interrupted}) expr = FullTextSearch()
|
LOOKAHEAD( 3 , {getAsBoolean(Feature.allowComplexParsing) && !interrupted} ) expr=Function()
LOOKAHEAD( Function() , {getAsBoolean(Feature.allowComplexParsing) && !interrupted} ) expr=Function()
|
LOOKAHEAD( 2, {!interrupted} ) expr=Column()
|
token=<S_CHAR_LITERAL> { expr = new StringValue(token.image); }
|
LOOKAHEAD( {!interrupted} ) "(" expr=ParenthesedSelect() ")"
LOOKAHEAD(ParenthesedExpression(), {getAsBoolean(Feature.allowComplexParsing)} ) expr = ParenthesedExpression()
|
LOOKAHEAD( 3, {getAsBoolean(Feature.allowComplexParsing) && !interrupted}) expr=ParenthesedSelect()

)

(
Expand Down Expand Up @@ -6607,7 +6622,7 @@ CreateFunctionalStatement CreateFunctionStatement(boolean isUsingOrReplace):
|
<K_PROCEDURE> { statementType = "PROCEDURE"; }
)
tokens=captureRest()
tokens=captureFunctionBody()
{
if(statementType.equals("FUNCTION")) {
type = new CreateFunction(isUsingOrReplace, tokens);
Expand Down Expand Up @@ -6683,6 +6698,36 @@ List<String> captureRest() {
return tokens;
}

/**
* Reads the tokens of a function or procedure body.
* A function body can end in 2 ways:
* 1) BEGIN...END;
* 2) Postgres: $$...$$...;
*/

JAVACODE
List<String> captureFunctionBody() {
List<String> tokens = new LinkedList<String>();
Token tok;
boolean foundEnd = false;
while(true) {
tok = getToken(1);
int l = tokens.size();
if( tok.kind == EOF || ( foundEnd && tok.kind == ST_SEMICOLON) ) {
break;
} else if ( l>0 && ( tok.image.equals(".") || tokens.get(l-1).endsWith(".")) ) {
tokens.set(l-1, tokens.get(l-1) + tok.image);
} else {
tokens.add(tok.image);
}
foundEnd |= (tok.kind == K_END)
|| ( tok.image.trim().startsWith("$$") && tok.image.trim().endsWith("$$")) ;

tok = getNextToken();
}
return tokens;
}

JAVACODE
List<String> captureUnsupportedStatementDeclaration() {
List<String> tokens = new LinkedList<String>();
Expand Down
76 changes: 76 additions & 0 deletions src/test/java/net/sf/jsqlparser/expression/JsonExpressionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import net.sf.jsqlparser.test.TestUtils;
import org.junit.jupiter.api.Test;

import static net.sf.jsqlparser.test.TestUtils.assertSqlCanBeParsedAndDeparsed;

class JsonExpressionTest {

@Test
Expand All @@ -33,4 +35,78 @@ void testIssue1792() throws JSQLParserException, InterruptedException {
+ " END";
TestUtils.assertSqlCanBeParsedAndDeparsed(sqlStr, true);
}

@Test
void testParenthesedJsonExpressionsIssue1792() throws JSQLParserException {
String sqlStr =
"SELECT table_a.b_e_t,\n"
+ " CASE\n"
+ " WHEN table_a.g_o_a_c IS NULL THEN 'a'\n"
+ " ELSE table_a.g_o_a_c\n"
+ " END AS e_cd,\n"
+ " CASE\n"
+ " WHEN table_a.a_f_t IS NULL THEN 'b'\n"
+ " ELSE table_a.a_f_t\n"
+ " END AS a_f_t,\n"
+ " COUNT(1) AS count,\n"
+ " ROUND(ABS(SUM(table_a.gb_eq))::NUMERIC, 2) AS total_x\n"
+ "FROM (SELECT table_x.b_e_t,\n"
+ " table_x.b_e_a,\n"
+ " table_y.g_o_a_c,\n"
+ " table_z.a_f_t,\n"
+ " CASE\n"
+ " WHEN table_x.b_e_a IS NOT NULL THEN table_x.b_e_a::DOUBLE PRECISION /\n"
+ " schema_z.g_c_r(table_x.c_c,\n"
+ " 'x'::CHARACTER VARYING,\n"
+ " table_x.r_ts::DATE)\n"
+ " ELSE\n"
+ " CASE\n"
+ " WHEN table_x.b_e_t::TEXT = 'p_e'::TEXT THEN (SELECT ((\n"
+ " (table_x.pld::JSON -> 'p_d'::TEXT) ->>\n"
+ " 's_a'::TEXT)::DOUBLE PRECISION) / schema_z.g_c_r(fba.s_c_c,\n"
+ " 'x'::CHARACTER VARYING,\n"
+ " table_x.r_ts::DATE)\n"
+ " FROM schema_z.f_b_a fba\n"
+ " JOIN schema_z.t_b_a_n_i table_y\n"
+ " ON fba.b_a_i = table_y.f_b_a_id\n"
+ " WHERE table_y.t_ngn_id =\n"
+ " (((table_x.pld::JSON -> 'p_d'::TEXT) ->>\n"
+ " 's_a_i'::TEXT)::BIGINT))\n"
+ " WHEN table_x.b_e_t::TEXT = 'i_e'::TEXT\n"
+ " THEN (SELECT (((table_x.pld::JSON -> 'i_d'::TEXT) ->> 'a'::TEXT)::DOUBLE PRECISION) /\n"
+ " schema_z.g_c_r(fba.s_c_c, 'x'::CHARACTER VARYING,\n"
+ " table_x.r_ts::DATE)\n"
+ " FROM schema_z.f_b_a fba\n"
+ " JOIN schema_z.t_b_a_n_i table_y\n"
+ " ON fba.b_a_i = table_y.f_b_a_id\n"
+ " WHERE table_y.t_ngn_id = (((table_x.pld::JSON -> 'i_d'::TEXT) ->>\n"
+ " 's_a_i'::TEXT)::BIGINT))\n"
+ " WHEN table_x.b_e_t::TEXT = 'i_e_2'::TEXT\n"
+ " THEN (SELECT (((table_x.pld::JSON -> 'i_d'::TEXT) ->> 'a'::TEXT)::DOUBLE PRECISION) /\n"
+ " schema_z.g_c_r(fba.s_c_c, 'x'::CHARACTER VARYING,\n"
+ " table_x.r_ts::DATE)\n"
+ " FROM schema_z.f_b_a fba\n"
+ " JOIN schema_z.t_b_a_n_i table_y\n"
+ " ON fba.b_a_i = table_y.f_b_a_id\n"
+ " WHERE table_y.t_ngn_id = (((table_x.pld::JSON -> 'id'::TEXT) ->>\n"
+ " 'd_i'::TEXT)::BIGINT))\n"
+ " WHEN table_x.b_e_t::TEXT = 'm_e'::TEXT\n"
+ " THEN (SELECT (((table_x.pld::JSON -> 'o'::TEXT) ->> 'eda'::TEXT)::DOUBLE PRECISION) /\n"
+ " schema_z.g_c_r(\n"
+ " ((table_x.pld::JSON -> 'o'::TEXT) ->> 'dc'::TEXT)::CHARACTER VARYING,\n"
+ " 'x'::CHARACTER VARYING, table_x.r_ts::DATE))\n"
+ " ELSE NULL::DOUBLE PRECISION\n"
+ " END\n"
+ " END AS gb_eq\n"
+ " FROM schema_z.baz\n"
+ " LEFT JOIN f_ctl.g_o_f_e_t_a_m table_y\n"
+ " ON table_x.p_e_m LIKE table_y.f_e_m_p\n"
+ " LEFT JOIN f_ctl.g_o_c_a_t table_z\n"
+ " ON table_z.c_a_t_c = table_y.g_o_a_c\n"
+ " WHERE table_x.p_st = 'E'\n"
+ " ) table_a\n"
+ "GROUP BY 1, 2, 3";

assertSqlCanBeParsedAndDeparsed(sqlStr, true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.function.Executable;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

public class UnsupportedStatementTest {
Expand Down Expand Up @@ -99,4 +100,25 @@ void testCreate() throws JSQLParserException {
statement = TestUtils.assertSqlCanBeParsedAndDeparsed(sqlStr, true);
assertTrue(statement instanceof UnsupportedStatement);
}

@Test
void testFunctions() throws JSQLParserException {
String sqlStr =
"CREATE OR REPLACE FUNCTION func_example(foo integer)\n"
+ "RETURNS integer AS $$\n"
+ "BEGIN\n"
+ " RETURN foo + 1;\n"
+ "END\n"
+ "$$ LANGUAGE plpgsql;\n"
+ "\n"
+ "CREATE OR REPLACE FUNCTION func_example2(IN foo integer, OUT bar integer)\n"
+ "AS $$\n"
+ "BEGIN\n"
+ " SELECT foo + 1 INTO bar;\n"
+ "END\n"
+ "$$ LANGUAGE plpgsql;";

Statements statements = CCJSqlParserUtil.parseStatements(sqlStr);
assertEquals(2, statements.size());
}
}
19 changes: 11 additions & 8 deletions src/test/java/net/sf/jsqlparser/statement/select/PostgresTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,17 @@ public void testExtractFunction() throws JSQLParserException {

@Test
public void testExtractFunctionIssue1582() throws JSQLParserException {
String sqlStr = "" + "select\n" + " t0.operatienr\n" + " , case\n"
+ " when\n"
+ " case when (t0.vc_begintijd_operatie is null or lpad((extract('hours' from t0.vc_begintijd_operatie::timestamp))::text,2,'0') ||':'|| lpad(extract('minutes' from t0.vc_begintijd_operatie::timestamp)::text,2,'0') = '00:00') then null\n"
+ " else (greatest(((extract('hours' from (t0.vc_eindtijd_operatie::timestamp-t0.vc_begintijd_operatie::timestamp))*60 + extract('minutes' from (t0.vc_eindtijd_operatie::timestamp-t0.vc_begintijd_operatie::timestamp)))/60)::numeric(12,2),0))*60\n"
+ " end = 0 then null\n"
+ " else '25. Meer dan 4 uur'\n"
+ " end \n"
+ " as snijtijd_interval";
String sqlStr = ""
+ "select\n"
+ " t0.operatienr\n"
+ " , case\n"
+ " when\n"
+ " case when (t0.vc_begintijd_operatie is null or lpad((extract('hours' from t0.vc_begintijd_operatie::timestamp))::text,2,'0') ||':'|| lpad(extract('minutes' from t0.vc_begintijd_operatie::timestamp)::text,2,'0') = '00:00') then null\n"
+ " else (greatest(((extract('hours' from (t0.vc_eindtijd_operatie::timestamp-t0.vc_begintijd_operatie::timestamp))*60 + extract('minutes' from (t0.vc_eindtijd_operatie::timestamp-t0.vc_begintijd_operatie::timestamp)))/60)::numeric(12,2),0))*60\n"
+ " end = 0 then null\n"
+ " else '25. Meer dan 4 uur'\n"
+ " end\n"
+ " as snijtijd_interval";
TestUtils.assertSqlCanBeParsedAndDeparsed(sqlStr, true);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;

import static net.sf.jsqlparser.test.TestUtils.assertDeparse;
import static net.sf.jsqlparser.test.TestUtils.assertExpressionCanBeDeparsedAs;
Expand Down