Skip to content

Commit

Permalink
fix #250 remove first comma regexp fixed.
Browse files Browse the repository at this point in the history
  • Loading branch information
HidekiSugimoto189 committed Mar 16, 2020
1 parent 24111eb commit 3b4caf7
Show file tree
Hide file tree
Showing 5 changed files with 192 additions and 77 deletions.
4 changes: 2 additions & 2 deletions README.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ Installation
<dependency>
<groupId>jp.co.future</groupId>
<artifactId>uroborosql</artifactId>
<version>0.17.0</version>
<version>0.17.1</version>
</dependency>
```

#### for Gradle

```gradle
compile group: 'jp.co.future', name: 'uroborosql', version: '0.17.0'
compile group: 'jp.co.future', name: 'uroborosql', version: '0.17.1'
```

Documentation
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ Installation
<dependency>
<groupId>jp.co.future</groupId>
<artifactId>uroborosql</artifactId>
<version>0.17.0</version>
<version>0.17.1</version>
</dependency>
```

#### for Gradle

```gradle
compile group: 'jp.co.future', name: 'uroborosql', version: '0.17.0'
compile group: 'jp.co.future', name: 'uroborosql', version: '0.17.1'
```

Documentation
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>jp.co.future</groupId>
<artifactId>uroborosql</artifactId>
<version>0.18.0-SNAPSHOT</version>
<version>0.17.1</version>
<packaging>jar</packaging>
<name>uroboroSQL</name>
<description>Developer-oriented and SQL centric database access library</description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,12 @@ public boolean contains(final Object o) {

/** where句の直後にくるANDやORを除外するための正規表現 */
protected static final Pattern WHERE_CLAUSE_PATTERN = Pattern
.compile("(?i)(WHERE\\s+(--.*|/\\*.*\\*/\\s*)*\\s*)(AND\\s+|OR\\s+)");
.compile("(?i)(?<clause>(^|\\s+)(WHERE\\s+(--.*|/\\*.*\\*/\\s*)*\\s*))(AND\\s+|OR\\s+)");

/** 各句の最初に現れるカンマを除去するための正規表現 */
protected static final Pattern REMOVE_FIRST_COMMA_PATTERN = Pattern
.compile("(?i)(((SELECT|ORDER\\s+BY|GROUP\\s+BY|SET)\\s+|\\(\\s*)(--.*|/\\*.*\\*/\\s*)*\\s*)(,)");
.compile(
"(?i)(?<keyword>((^|\\s+)(SELECT|ORDER\\s+BY|GROUP\\s+BY|SET)\\s+|\\(\\s*)(--.*|/\\*.*\\*/\\s*)*\\s*)(,)");
/** 不要な空白、改行を除去するための正規表現 */
protected static final Pattern CLEAR_BLANK_PATTERN = Pattern.compile("(?m)^\\s*(\\r\\n|\\r|\\n)");

Expand Down Expand Up @@ -222,7 +223,7 @@ public String getExecutableSql() {
StringBuffer buff = new StringBuffer();
Matcher matcher = WHERE_CLAUSE_PATTERN.matcher(executableSqlCache);
while (matcher.find()) {
String whereClause = matcher.group(1);
String whereClause = matcher.group("clause");
matcher.appendReplacement(buff, whereClause);
}
matcher.appendTail(buff);
Expand All @@ -232,7 +233,7 @@ public String getExecutableSql() {
StringBuffer buff = new StringBuffer();
Matcher removeCommaMatcher = REMOVE_FIRST_COMMA_PATTERN.matcher(executableSqlCache);
while (removeCommaMatcher.find()) {
String clauseWords = removeCommaMatcher.group(1);
String clauseWords = removeCommaMatcher.group("keyword");
removeCommaMatcher.appendReplacement(buff, clauseWords);
}
removeCommaMatcher.appendTail(buff);
Expand Down
Loading

0 comments on commit 3b4caf7

Please sign in to comment.