#1193 - For RawSql ignore the Postgres cast double colon like ::text

This commit is contained in:
rob bygrave
2017-11-02 00:03:38 +13:00
parent 66fe278e3f
commit 10eb2bc21f
4 changed files with 89 additions and 4 deletions
@@ -105,7 +105,7 @@ public class BindParamsParser {
// search for quotes and named params... in order...
int beginQuotePos = sql.indexOf(quote, startPos);
int nameParamStart = sql.indexOf(colon, startPos);
int nameParamStart = findNameStart(sql, startPos);
if (beginQuotePos > 0 && beginQuotePos < nameParamStart) {
// the quote precedes the named parameter...
// find and add up to the end quote
@@ -180,6 +180,23 @@ public class BindParamsParser {
}
}
/**
* Find the next named parameter start position (based on colon).
*/
static int findNameStart(String sql, int startPos) {
int colonPos = sql.indexOf(colon, startPos);
if (colonPos > -1) {
// validate the next character after the colon (ignore postgres cast)
char c = sql.charAt(colonPos + 1);
if (c == '_' || Character.isLetterOrDigit(c)) {
return colonPos;
} else {
return findNameStart(sql, colonPos + 2);
}
}
return -1;
}
/**
* Add an encryption key bind parameter.
*/