Skip to content

Commit c3b4046

Browse files
committed
workaround for mySql truncate function
1 parent f7e0a1e commit c3b4046

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/main/javacc/net/sf/jsqlparser/parser/JSqlParserCC.jj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1884,6 +1884,9 @@ Function Function():
18841884
|
18851885
// workaround for replace(string) function (name clash with mysql REPLACE expression)
18861886
<K_REPLACE> { funcName = "REPLACE"; }
1887+
|
1888+
// workaround for truncate(string) function (name clash with mysql TRUNCATE expression)
1889+
<K_TRUNCATE> { funcName = "TRUNCATE"; }
18871890
) [ "." tmp=RelObjectName() { funcName+= "." + tmp; } ["." tmp=RelObjectName() { funcName+= "." + tmp; }]]
18881891
"(" [ [<K_DISTINCT> { retval.setDistinct(true); } | <K_ALL> { retval.setAllColumns(true); }] (expressionList=SimpleExpressionList() | "*" { retval.setAllColumns(true); }) ] ")"
18891892

src/test/java/net/sf/jsqlparser/test/select/SelectTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -901,6 +901,11 @@ public void testProblemFunction2() throws JSQLParserException {
901901
String stmt = "SELECT sysdate FROM testtable";
902902
assertSqlCanBeParsedAndDeparsed(stmt);
903903
}
904+
905+
public void testProblemFunction3() throws JSQLParserException {
906+
String stmt = "SELECT TRUNCATE(col) FROM testtable";
907+
assertSqlCanBeParsedAndDeparsed(stmt);
908+
}
904909

905910
public void testAdditionalLettersGerman() throws JSQLParserException {
906911
String stmt = "SELECT colä, colö, colü FROM testtableäöü";

0 commit comments

Comments
 (0)