@@ -1119,9 +1119,8 @@ public void testFunctions() throws JSQLParserException {
11191119 assertEquals ("MAX" , fun .getName ());
11201120 assertEquals ("b" , ((Column ) fun .getParameters ().getExpressions ().get (1 )).
11211121 getFullyQualifiedName ());
1122- assertTrue (((Function ) ((SelectExpressionItem ) plainSelect .getSelectItems ().get (1 )).
1123- getExpression ())
1124- .isAllColumns ());
1122+ assertTrue ( ((Function ) ((SelectExpressionItem ) plainSelect .getSelectItems ().get (1 )).
1123+ getExpression ()).getParameters ().getExpressions ().get (0 ) instanceof AllColumns );
11251124 assertStatementCanBeDeparsedAs (select , statement );
11261125
11271126 statement = "SELECT {fn MAX(a, b, c)}, COUNT(*), D FROM tab1 GROUP BY D" ;
@@ -1133,9 +1132,8 @@ public void testFunctions() throws JSQLParserException {
11331132 assertEquals ("MAX" , fun .getName ());
11341133 assertEquals ("b" , ((Column ) fun .getParameters ().getExpressions ().get (1 )).
11351134 getFullyQualifiedName ());
1136- assertTrue (((Function ) ((SelectExpressionItem ) plainSelect .getSelectItems ().get (1 )).
1137- getExpression ())
1138- .isAllColumns ());
1135+ assertTrue ( ((Function ) ((SelectExpressionItem ) plainSelect .getSelectItems ().get (1 )).
1136+ getExpression ()).getParameters ().getExpressions ().get (0 ) instanceof AllColumns );
11391137 assertStatementCanBeDeparsedAs (select , statement );
11401138
11411139 statement = "SELECT ab.MAX(a, b, c), cd.COUNT(*), D FROM tab1 GROUP BY D" ;
@@ -1149,7 +1147,7 @@ public void testFunctions() throws JSQLParserException {
11491147 fun = (Function ) ((SelectExpressionItem ) plainSelect .getSelectItems ().get (1 )).
11501148 getExpression ();
11511149 assertEquals ("cd.COUNT" , fun .getName ());
1152- assertTrue (fun .isAllColumns () );
1150+ assertTrue (fun .getParameters (). getExpressions (). get ( 0 ) instanceof AllColumns );
11531151 assertStatementCanBeDeparsedAs (select , statement );
11541152 }
11551153
@@ -4822,4 +4820,40 @@ public void testReservedKeywordsMSSQLUseIndexIssue1325() throws JSQLParserExcept
48224820 assertSqlCanBeParsedAndDeparsed (
48234821 "SELECT col FROM table USE INDEX(primary)" , true );
48244822 }
4823+
4824+ @ Test
4825+ public void testTableSpaceKeyword () throws JSQLParserException {
4826+ // without extra brackets
4827+ assertSqlCanBeParsedAndDeparsed (
4828+ "SELECT DDF.tablespace TABLESPACE_NAME\n " +
4829+ " , maxtotal / 1024 / 1024 \" MAX_MB\" \n " +
4830+ " , ( total - free ) / 1024 / 1024 \" USED_MB\" \n " +
4831+ " , ( maxtotal - ( total - free ) ) / 1024 / 1024 \" AVAILABLE_MB\" \n " +
4832+ " , total / 1024 / 1024 \" ALLOCATED_MB\" \n " +
4833+ " , free / 1024 / 1024 \" ALLOCATED_FREE_MB\" \n " +
4834+ " , ( ( total - free ) / maxtotal * 100 ) \" USED_PERC\" \n " +
4835+ " , cnt \" FILE_COUNT\" \n " +
4836+ " FROM (SELECT tablespace_name TABLESPACE\n " +
4837+ " , SUM(bytes) TOTAL\n " +
4838+ " , SUM(Greatest(maxbytes, bytes)) MAXTOTAL\n " +
4839+ " , Count(*) CNT\n " +
4840+ " FROM dba_data_files\n " +
4841+ " GROUP BY tablespace_name) DDF\n " +
4842+ " , (SELECT tablespace_name TABLESPACE\n " +
4843+ " , SUM(bytes) FREE\n " +
4844+ " , Max(bytes) MAXF\n " +
4845+ " FROM dba_free_space\n " +
4846+ " GROUP BY tablespace_name) DFS\n " +
4847+ " WHERE DDF.tablespace = DFS.tablespace\n " +
4848+ " ORDER BY 1 DESC" , true );
4849+ }
4850+
4851+ @ Test
4852+ public void testTableSpecificAllColumnsIssue1346 () throws JSQLParserException {
4853+ assertSqlCanBeParsedAndDeparsed (
4854+ "SELECT count(*) from a" , true );
4855+
4856+ assertSqlCanBeParsedAndDeparsed (
4857+ "SELECT count(a.*) from a" , true );
4858+ }
48254859}
0 commit comments