Skip to content

Commit ea4152f

Browse files
committed
test: nit fixes
1 parent 218c3b7 commit ea4152f

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/AbstractStatementParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ static int countOccurrencesOf(char c, String string) {
551551
* @return A boolean indicating whether the sql string has a Returning clause or not.
552552
*/
553553
@InternalApi
554-
abstract boolean checkReturningClauseInternal(String sql);
554+
abstract protected boolean checkReturningClauseInternal(String sql);
555555

556556
@InternalApi
557557
public boolean checkReturningClause(String sql) {

google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/PostgreSQLStatementParser.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
public class PostgreSQLStatementParser extends AbstractStatementParser {
3333
private static final Pattern RETURNING_PATTERN = Pattern.compile("[ ')\"]returning[ '(\"]");
3434
private static final Pattern AS_RETURNING_PATTERN = Pattern.compile("[ ')\"]as returning[ '(\"]");
35+
private static final String RETURNING_STRING = "returning";
3536

3637
PostgreSQLStatementParser() throws CompileException {
3738
super(
@@ -305,12 +306,12 @@ private boolean isReturning(String sql, int index) {
305306

306307
@InternalApi
307308
@Override
308-
boolean checkReturningClauseInternal(String rawSql) {
309+
protected boolean checkReturningClauseInternal(String rawSql) {
309310
Preconditions.checkNotNull(rawSql);
310311
String sql = rawSql.toLowerCase();
311312
// Do a pre-check to check if the SQL string definitely does not have a returning clause.
312313
// If this check fails, do a more involved check to check for a returning clause.
313-
if (!sql.contains("returning")) {
314+
if (!sql.contains(RETURNING_STRING)) {
314315
return false;
315316
}
316317
sql = sql.replaceAll("\\s+", " ");

google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/SpannerStatementParser.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@
3030
@InternalApi
3131
public class SpannerStatementParser extends AbstractStatementParser {
3232

33-
final Pattern THEN_RETURN_PATTERN = Pattern.compile("[ `')\"]then return[ `'(\"]");
33+
private static final Pattern THEN_RETURN_PATTERN = Pattern.compile("[ `')\"]then return[ `'(\"]");
34+
private static final String THEN_STRING = "then";
35+
private static final String RETURN_STRING = "return";
3436

3537
public SpannerStatementParser() throws CompileException {
3638
super(
@@ -280,12 +282,12 @@ private boolean isReturning(String sql, int index) {
280282

281283
@InternalApi
282284
@Override
283-
boolean checkReturningClauseInternal(String rawSql) {
285+
protected boolean checkReturningClauseInternal(String rawSql) {
284286
Preconditions.checkNotNull(rawSql);
285287
String sql = rawSql.toLowerCase();
286288
// Do a pre-check to check if the SQL string definitely does not have a returning clause.
287289
// If this check fails, do a more involved check to check for a returning clause.
288-
if (!(sql.contains("then") && sql.contains("return"))) {
290+
if (!(sql.contains(THEN_STRING) && sql.contains(RETURN_STRING))) {
289291
return false;
290292
}
291293
sql = sql.replaceAll("\\s+", " ");

0 commit comments

Comments
 (0)