Skip to content

Instantly share code, notes, and snippets.

@metametaclass
Created October 10, 2012 07:51
Show Gist options
  • Save metametaclass/3863870 to your computer and use it in GitHub Desktop.
Save metametaclass/3863870 to your computer and use it in GitHub Desktop.
/**
* Check if the target SQL contains at least one of the escaped syntax
* commands. This method performs simple substring matching, so it may
* report that SQL contains escaped syntax when the <code>"{"</code>
* is followed by the escaped syntax command in regular string constants
* that are passed as parameters. In this case {@link #parse(String)} will
* perform complete SQL parsing.
*
* @param sql to test
* @return <code>true</code> if the <code>sql</code> is suspected to contain
* escaped syntax.
*/
protected boolean checkForEscapes(String sql) {
sql = sql.toLowerCase();
return sql.indexOf(CHECK_CALL_1) != -1 ||
sql.indexOf(CHECK_CALL_2) != -1 ||
sql.indexOf(CHECK_DATE) != -1 ||
sql.indexOf(CHECK_ESCAPE) != -1 ||
sql.indexOf(CHECK_FUNCTION) != -1 ||
sql.indexOf(CHECK_OUTERJOIN) != -1 ||
sql.indexOf(CHECK_TIME) != -1 ||
sql.indexOf(CHECK_TIMESTAMP) != -1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment