Permalink
Browse files

fix:bugs with parse

  • Loading branch information...
davecramer committed Apr 15, 2016
1 parent 2032836 commit 72945b04279613828cc32d97cc86317a73feb1fd
@@ -427,12 +427,12 @@ public static boolean parseDeleteKeyword(final char[] query, int offset) {
return false;
}
return Character.toUpperCase(query[offset + 1]) == 'd'
&& Character.toUpperCase(query[offset + 1]) == 'e'
&& Character.toUpperCase(query[offset + 2]) == 'l'
&& Character.toUpperCase(query[offset + 3]) == 'e'
&& Character.toUpperCase(query[offset + 4]) == 't'
&& Character.toUpperCase(query[offset + 5]) == 'e';
return (query[offset ] | 32) == 'd'
&& (query[offset + 1] | 32) == 'e'
&& (query[offset + 2] | 32) == 'l'
&& (query[offset + 3] | 32) == 'e'
&& (query[offset + 4] | 32) == 't'
&& (query[offset + 5] | 32) == 'e';
}
/**
@@ -465,10 +465,10 @@ public static boolean parseMoveKeyword(final char[] query, int offset) {
return false;
}
return Character.toUpperCase(query[offset + 1]) == 'm'
&& Character.toUpperCase(query[offset + 1]) == 'o'
&& Character.toUpperCase(query[offset + 2]) == 'v'
&& Character.toUpperCase(query[offset + 3]) == 'e';
return (query[offset] | 32) == 'm'
&& (query[offset + 1] | 32) == 'o'
&& (query[offset + 2] | 32) == 'v'
&& (query[offset + 3] | 32) == 'e';
}
/**
@@ -504,12 +504,12 @@ public static boolean parseUpdateKeyword(final char[] query, int offset) {
return false;
}
return Character.toUpperCase(query[offset + 1]) == 'u'
&& Character.toUpperCase(query[offset + 1]) == 'p'
&& Character.toUpperCase(query[offset + 2]) == 'd'
&& Character.toUpperCase(query[offset + 3]) == 'a'
&& Character.toUpperCase(query[offset + 4]) == 't'
&& Character.toUpperCase(query[offset + 5]) == 'e';
return (query[offset] | 32) == 'u'
&& (query[offset + 1] | 32) == 'p'
&& (query[offset + 2] | 32) == 'd'
&& (query[offset + 3] | 32) == 'a'
&& (query[offset + 4] | 32) == 't'
&& (query[offset + 5] | 32) == 'e';
}
/**
@@ -89,6 +89,17 @@ public void testHasReturning() {
}
public void testHasDelete()
{
List<NativeQuery> queries = Parser.parseJdbcSql("delete from foo where a=1", true, true, false, true, true);
NativeQuery query = queries.get(0);
assertTrue("This is a delete command", query.command.getType() == DMLCommandType.DELETE);
queries = Parser.parseJdbcSql("update foo set (a=?,b=?,c=?)", true, true, false, true, true);
query = queries.get(0);
assertFalse("This is not a delete command", query.command.getType() == DMLCommandType.DELETE);
}
public void testIsInsert() {
List<NativeQuery> queries = Parser.parseJdbcSql("insert into foo (a,b,c) values (?,?,?) returning a", true, true, false, true, true);
@@ -97,7 +108,7 @@ public void testIsInsert() {
queries = Parser.parseJdbcSql("update foo set (a=?,b=?,c=?)", true, true, false, true, true);
query = queries.get(0);
assertFalse("This is an insert command", query.command.getType() == DMLCommandType.INSERT);
assertFalse("This is not insert command", query.command.getType() == DMLCommandType.INSERT);
queries = Parser.parseJdbcSql("select 1 as insert", true, true, false, true, true);
query = queries.get(0);

0 comments on commit 72945b0

Please sign in to comment.