-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
JCES-1896 removing internal state isWriteOperation to depend on Reaso…
…n.isWrite(), introducing SqlQuery to improve OO impl
- Loading branch information
1 parent
989c6b0
commit e69f2a9
Showing
4 changed files
with
51 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/main/java/com/atlassian/db/replica/internal/SqlQuery.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.atlassian.db.replica.internal; | ||
|
||
public final class SqlQuery { | ||
|
||
private final String sql; | ||
|
||
public SqlQuery(String sql) { | ||
this.sql = sql; | ||
} | ||
|
||
boolean isWriteOperation(SqlFunction sqlFunction) { | ||
return sqlFunction.isFunctionCall(sql) || isUpdate() || isDelete(); | ||
} | ||
|
||
boolean isSelectForUpdate() { | ||
return sql != null && (sql.endsWith("for update") || sql.endsWith("FOR UPDATE")); | ||
} | ||
|
||
boolean isSqlSet() { | ||
return sql.startsWith("set"); | ||
} | ||
|
||
private boolean isUpdate() { | ||
return sql != null && (sql.startsWith("update") || sql.startsWith("UPDATE")); | ||
} | ||
|
||
private boolean isDelete() { | ||
return sql != null && (sql.startsWith("delete") || sql.startsWith("DELETE")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters