Skip to content

Commit a00d77a

Browse files
Assorted Fixes #5 (#1715)
* refactor: Merge REPLACE into UPSERT fixes #1706 * feat: `DROP TEMPORARY TABLE ...` fixes #1712 * build: PMD compliance * ci: Merge master * feat: Configurable backslash `\` escaping - Enables `\` as escape character in String Literals (beside SQL:2016 compliant `'`) - Default is OFF (since its not SQL:2016 compliant) - Activate per Parser Feature - Fixes #1638 - Fixes #1209 - Fixes #1173 - Fixes #1172 - Fixes #832 - Fixes #827 - Fixes #578 BREAKING-CHANGE: Backslash Escaping needs to be activated explicitly or else Backslash won't work as Escape Character. * style: Checkstyle * style: remove dead code * style: PMD compliance * style: Checkstyle, unused import * feat: allow `S_CHAR_LITERAL` to break lines - fixes #875
1 parent 1af682d commit a00d77a

File tree

29 files changed

+612
-438
lines changed

29 files changed

+612
-438
lines changed

build.gradle

-3
Original file line numberDiff line numberDiff line change
@@ -180,15 +180,12 @@ spotbugs {
180180

181181
pmd {
182182
consoleOutput = false
183-
toolVersion = "6.46.0"
184-
185183
sourceSets = [sourceSets.main]
186184

187185
// clear the ruleset in order to use configured rules only
188186
ruleSets = []
189187

190188
//rulesMinimumPriority = 1
191-
192189
ruleSetFiles = files("config/pmd/ruleset.xml")
193190

194191
pmdMain {

config/pmd/ruleset.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ under the License.
4848
<rule ref="category/java/codestyle.xml/UnnecessaryReturn" />
4949
<rule ref="category/java/codestyle.xml/UselessParentheses" />
5050
<rule ref="category/java/codestyle.xml/UselessQualifiedThis" />
51-
52-
<!-- for Codazy -->
51+
52+
<!-- for Codazy -->
5353
<rule ref="category/java/codestyle.xml/MethodNamingConventions">
5454
<properties>
5555
<property name="methodPattern" value="[a-z][a-zA-Z0-9]*" />

pom.xml

+3-84
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@
131131
<plugin>
132132
<groupId>org.apache.maven.plugins</groupId>
133133
<artifactId>maven-pmd-plugin</artifactId>
134-
<version>3.14.0</version>
134+
<version>3.19.0</version>
135135
<configuration>
136136
<rulesets>
137137
<!-- Custom local file system rule set -->
@@ -218,7 +218,7 @@
218218
<dependency>
219219
<groupId>net.java.dev.javacc</groupId>
220220
<artifactId>javacc</artifactId>
221-
<version>7.0.11</version>
221+
<version>7.0.12</version>
222222
</dependency>
223223
</dependencies>
224224
</plugin>
@@ -418,92 +418,11 @@
418418
<version>3.3.0</version>
419419
</plugin>
420420

421-
<!-- Cobertura is broken with Java 1.8 and there is not fix
422-
please refer to https://github.com/cobertura/cobertura/issues/248
423-
424-
<plugin>
425-
<groupId>org.codehaus.mojo</groupId>
426-
<artifactId>cobertura-maven-plugin</artifactId>
427-
<version>2.7</version>
428-
<configuration>
429-
<aggregate>true</aggregate>
430-
<outputDirectory>${project.reporting.outputDirectory}/cobertura</outputDirectory>
431-
</configuration>
432-
</plugin>
433-
-->
434-
435421
<plugin>
436422
<groupId>org.codehaus.mojo</groupId>
437423
<artifactId>findbugs-maven-plugin</artifactId>
438424
<version>3.0.5</version>
439425
</plugin>
440-
441-
<!-- Obsolete or Unused
442-
<plugin>
443-
<groupId>org.apache.maven.plugins</groupId>
444-
<artifactId>maven-checkstyle-plugin</artifactId>
445-
<configuration>
446-
<configLocation>config/sun_checks.xml</configLocation>
447-
</configuration>
448-
</plugin>
449-
-->
450-
451-
<!-- JJDoc report generating the BNF documentation -->
452-
<plugin>
453-
<groupId>org.javacc.plugin</groupId>
454-
<artifactId>javacc-maven-plugin</artifactId>
455-
<version>3.0.3</version>
456-
<configuration>
457-
<!--
458-
/**
459-
* A flag to specify the output format for the generated documentation. If set to <code>true</code>, JJDoc will
460-
* generate a plain text description of the BNF. Some formatting is done via tab characters, but the intention is to
461-
* leave it as plain as possible. Specifying <code>false</code> causes JJDoc to generate a hyperlinked HTML document
462-
* unless the parameter {@link #bnf} has been set to <code>true</code>. Default value is <code>false</code>.
463-
*
464-
* @parameter expression="${text}"
465-
*/
466-
-->
467-
<text>false</text>
468-
469-
<!--
470-
/**
471-
* A flag whether to generate a plain text document with the unformatted BNF. Note that setting this option to
472-
* <code>true</code> is only effective if the parameter {@link #text} is <code>false</code>. Default value is
473-
* <code>false</code>.
474-
*
475-
* @parameter expression="${bnf}"
476-
* @since 2.6
477-
*/
478-
-->
479-
<bnf>false</bnf>
480-
481-
<!--
482-
/**
483-
* This option controls the structure of the generated HTML output. If set to <code>true</code>, a single HTML
484-
* table for the entire BNF is generated. Setting it to <code>false</code> will produce one table for every
485-
* production in the grammar.
486-
*
487-
* @parameter expression="${oneTable}" default-value=true
488-
*/
489-
-->
490-
<oneTable>false</oneTable>
491-
492-
<!--
493-
/**
494-
* The hypertext reference to an optional CSS file for the generated HTML documents. If specified, this CSS file
495-
* will be included via a <code>&lt;link&gt;</code> element in the HTML documents. Otherwise, the default style will
496-
* be used.
497-
*
498-
* @parameter expression="${cssHref}"
499-
* @since 2.5
500-
*/
501-
-->
502-
<!-- <cssHref></cssHref> -->
503-
504-
<outputDirectory>${project.reporting.outputDirectory}</outputDirectory>
505-
</configuration>
506-
</plugin>
507426
</plugins>
508427
</reporting>
509428

@@ -628,7 +547,7 @@
628547

629548
<properties>
630549
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
631-
<pmdVersion>6.46.0</pmdVersion>
550+
<pmdVersion>6.53.0</pmdVersion>
632551
</properties>
633552

634553
<description>JSqlParser parses an SQL statement and translate it into a hierarchy of Java classes.

src/main/java/net/sf/jsqlparser/parser/AbstractJSqlParser.java

+4
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ public P withUnsupportedStatements(boolean allowUnsupportedStatements) {
3636
public P withTimeOut(int timeOutMillSeconds) {
3737
return withFeature(Feature.timeOut, timeOutMillSeconds);
3838
}
39+
40+
public P withBackslashEscapeCharacter(boolean allowBackslashEscapeCharacter) {
41+
return withFeature(Feature.allowBackslashEscapeCharacter, allowBackslashEscapeCharacter);
42+
}
3943

4044
public P withFeature(Feature f, boolean enabled) {
4145
getConfiguration().setValue(f, enabled);

src/main/java/net/sf/jsqlparser/parser/feature/Feature.java

+8-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
import net.sf.jsqlparser.statement.DeclareStatement;
2222
import net.sf.jsqlparser.statement.DescribeStatement;
2323
import net.sf.jsqlparser.statement.ExplainStatement;
24-
import net.sf.jsqlparser.statement.SetStatement;
2524
import net.sf.jsqlparser.statement.ResetStatement;
25+
import net.sf.jsqlparser.statement.SetStatement;
2626
import net.sf.jsqlparser.statement.ShowColumnsStatement;
2727
import net.sf.jsqlparser.statement.ShowStatement;
2828
import net.sf.jsqlparser.statement.UseStatement;
@@ -447,6 +447,7 @@ public enum Feature {
447447
*
448448
* @see Replace
449449
*/
450+
@Deprecated
450451
replace,
451452
/**
452453
* SQL "DROP" statement is allowed
@@ -758,7 +759,12 @@ public enum Feature {
758759
*/
759760
allowUnsupportedStatements(false),
760761

761-
timeOut( 6000)
762+
timeOut( 6000),
763+
764+
/**
765+
* allows Backslash '\' as Escape Character
766+
*/
767+
allowBackslashEscapeCharacter(false),
762768
;
763769

764770
private Object value;

src/main/java/net/sf/jsqlparser/statement/drop/Drop.java

+17-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ public class Drop implements Statement {
3030
private boolean ifExists = false;
3131
private boolean materialized = false;
3232

33+
private boolean isUsingTemporary;
34+
3335
@Override
3436
public void accept(StatementVisitor statementVisitor) {
3537
statementVisitor.visit(this);
@@ -67,6 +69,19 @@ public void setIfExists(boolean ifExists) {
6769
this.ifExists = ifExists;
6870
}
6971

72+
public boolean isUsingTemporary() {
73+
return isUsingTemporary;
74+
}
75+
76+
public void setUsingTemporary(boolean useTemporary) {
77+
this.isUsingTemporary=useTemporary;
78+
}
79+
80+
public Drop withUsingTemporary(boolean useTemporary) {
81+
setUsingTemporary(useTemporary);
82+
return this;
83+
}
84+
7085
public boolean isMaterialized() {
7186
return materialized;
7287
}
@@ -85,7 +100,8 @@ public void setTypeToParameters(Map<String, List<String>> typeToParameters) {
85100

86101
@Override
87102
public String toString() {
88-
String sql = "DROP "
103+
String sql = "DROP "
104+
+ (isUsingTemporary ? "TEMPORARY " : "")
89105
+ (materialized ? "MATERIALIZED " : "")
90106
+ type + " "
91107
+ (ifExists ? "IF EXISTS " : "") + name.toString();

0 commit comments

Comments
 (0)