Skip to content

Commit 0949df9

Browse files
Issue1500 - Circular References in AllColumns and AllTableColumns (#1501)
* Adjust Gradle to JUnit 5 Parallel Test execution Gradle Caching Explicitly request for latest JavaCC 7.0.10 * Do not mark SpeedTest for concurrent execution * Remove unused imports * Adjust Gradle to JUnit 5 Parallel Test execution Gradle Caching Explicitly request for latest JavaCC 7.0.10 * Do not mark SpeedTest for concurrent execution * Remove unused imports * Remove circular reference revealed by issue #1500 * Add test for Issue 1500 Circular reference for All Columns Expression * Fix Test case * Add Test for AllTableColumn due to similar circular reference * Remove similar circular reference from AllTableColumn * Update dependencies * Adjust Jacoco Missed Lines count
1 parent 62677a6 commit 0949df9

File tree

4 files changed

+29
-17
lines changed

4 files changed

+29
-17
lines changed

build.gradle

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,19 @@ repositories {
2929
}
3030

3131
dependencies {
32-
testImplementation 'commons-io:commons-io:2.6'
33-
testImplementation 'junit:junit:4.13.1'
34-
testImplementation 'org.mockito:mockito-core:2.28.2'
35-
testImplementation 'org.assertj:assertj-core:3.16.1'
36-
testImplementation 'org.apache.commons:commons-lang3:3.10'
37-
testImplementation 'com.h2database:h2:1.4.200'
32+
testImplementation 'commons-io:commons-io:2.11.0'
33+
testImplementation 'junit:junit:4.13.2'
34+
testImplementation 'org.mockito:mockito-core:4.3.1'
35+
testImplementation 'org.assertj:assertj-core:3.22.0'
36+
testImplementation 'org.apache.commons:commons-lang3:3.12.0'
37+
testImplementation 'com.h2database:h2:2.1.210'
3838

3939
// for JaCoCo Reports
40-
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.1'
40+
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2'
4141
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
4242

4343
// https://mvnrepository.com/artifact/org.mockito/mockito-junit-jupiter
44-
testImplementation 'org.mockito:mockito-junit-jupiter:4.1.0'
44+
testImplementation 'org.mockito:mockito-junit-jupiter:4.3.1'
4545

4646
// enforce latest version of JavaCC
4747
javacc 'net.java.dev.javacc:javacc:7.0.10'
@@ -115,7 +115,7 @@ jacocoTestCoverageVerification {
115115
limit {
116116
counter = 'LINE'
117117
value = 'MISSEDCOUNT'
118-
maximum = 5500
118+
maximum = 5513
119119
}
120120
excludes = [
121121
'net.sf.jsqlparser.util.validation.*',

src/main/java/net/sf/jsqlparser/expression/ExpressionVisitorAdapter.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -492,12 +492,10 @@ public void visit(UnPivot unpivot) {
492492

493493
@Override
494494
public void visit(AllColumns allColumns) {
495-
allColumns.accept((ExpressionVisitor) this);
496495
}
497496

498497
@Override
499498
public void visit(AllTableColumns allTableColumns) {
500-
allTableColumns.accept((ExpressionVisitor) this);
501499
}
502500

503501
@Override

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1020,9 +1020,12 @@ public void testDistinctTop2() {
10201020
public void testDistinctWithFollowingBrackets() throws JSQLParserException {
10211021
Select select = (Select) assertSqlCanBeParsedAndDeparsed("SELECT DISTINCT (phone), name FROM admin_user");
10221022
PlainSelect selectBody = (PlainSelect) select.getSelectBody();
1023+
Distinct distinct = selectBody.getDistinct();
1024+
10231025
assertThat(selectBody.getDistinct())
10241026
.isNotNull()
1025-
.hasFieldOrPropertyWithValue("getOnSelectItems", null);
1027+
.hasFieldOrPropertyWithValue("onSelectItems", null);
1028+
10261029
assertThat(selectBody.getSelectItems().get(0).toString())
10271030
.isEqualTo("(phone)");
10281031
}

src/test/java/net/sf/jsqlparser/util/deparser/StatementDeParserTest.java

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,7 @@
2323
import net.sf.jsqlparser.statement.execute.Execute;
2424
import net.sf.jsqlparser.statement.insert.Insert;
2525
import net.sf.jsqlparser.statement.replace.Replace;
26-
import net.sf.jsqlparser.statement.select.OrderByElement;
27-
import net.sf.jsqlparser.statement.select.Select;
28-
import net.sf.jsqlparser.statement.select.SelectBody;
29-
import net.sf.jsqlparser.statement.select.SubSelect;
30-
import net.sf.jsqlparser.statement.select.WithItem;
26+
import net.sf.jsqlparser.statement.select.*;
3127
import net.sf.jsqlparser.statement.update.Update;
3228
import net.sf.jsqlparser.statement.update.UpdateSet;
3329
import net.sf.jsqlparser.statement.upsert.Upsert;
@@ -370,4 +366,19 @@ public void shouldUseProvidedDeparsersWhenDeParsingIfThenStatement() throws JSQL
370366
statementDeParser.deParse(ifElseStatement);
371367
}
372368

369+
@Test
370+
public void testIssue1500AllColumns() throws JSQLParserException {
371+
String sqlStr = "select count(*) from some_table";
372+
Select select = (Select) CCJSqlParserUtil.parse(sqlStr);
373+
PlainSelect selectBody = (PlainSelect) select.getSelectBody();
374+
selectBody.accept(new SelectDeParser());
375+
}
376+
377+
@Test
378+
public void testIssue1500AllTableColumns() throws JSQLParserException {
379+
String sqlStr = "select count(a.*) from some_table a";
380+
Select select = (Select) CCJSqlParserUtil.parse(sqlStr);
381+
PlainSelect selectBody = (PlainSelect) select.getSelectBody();
382+
selectBody.accept(new SelectDeParser());
383+
}
373384
}

0 commit comments

Comments
 (0)