mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#1193 - For RawSql ignore the Postgres cast double colon like ::text
This commit is contained in:
@@ -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.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user