HHH-7721 SQLFunctionRegistry findSQLFunction does not honor case

sensitivity
This commit is contained in:
brmeyer 2012-10-26 14:39:19 -04:00
parent c46c04631d
commit 4e434f6197
4 changed files with 7 additions and 5 deletions

View File

@ -2418,7 +2418,9 @@ public class Configuration implements Serializable {
}
public void addSqlFunction(String functionName, SQLFunction function) {
sqlFunctions.put( functionName, function );
// HHH-7721: SQLFunctionRegistry expects all lowercase. Enforce,
// just in case a user's customer dialect uses mixed cases.
sqlFunctions.put( functionName.toLowerCase(), function );
}
public TypeResolver getTypeResolver() {

View File

@ -598,7 +598,9 @@ public abstract class Dialect implements ConversionContext {
// function support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
protected void registerFunction(String name, SQLFunction function) {
sqlFunctions.put( name, function );
// HHH-7721: SQLFunctionRegistry expects all lowercase. Enforce,
// just in case a user's customer dialect uses mixed cases.
sqlFunctions.put( name.toLowerCase(), function );
}
/**

View File

@ -38,7 +38,6 @@ public class SQLFunctionRegistry {
}
public SQLFunction findSQLFunction(String functionName) {
// TODO: lower casing done here. Was done "at random" before; maybe not needed at all ?
String name = functionName.toLowerCase();
SQLFunction userFunction = userFunctions.get( name );
return userFunction != null
@ -47,7 +46,6 @@ public class SQLFunctionRegistry {
}
public boolean hasFunction(String functionName) {
// TODO: toLowerCase was not done before. Only used in Template.
String name = functionName.toLowerCase();
return userFunctions.containsKey( name ) || dialect.getFunctions().containsKey( name );
}

View File

@ -361,7 +361,7 @@ public class SessionFactoryHelper {
* @return The sql function, or null if not found.
*/
public SQLFunction findSQLFunction(String functionName) {
return sfi.getSqlFunctionRegistry().findSQLFunction( functionName.toLowerCase() );
return sfi.getSqlFunctionRegistry().findSQLFunction( functionName );
}
/**