Skip to content

Commit

Permalink
HHH-7721 SQLFunctionRegistry findSQLFunction does not honor case
Browse files Browse the repository at this point in the history
sensitivity
  • Loading branch information
brmeyer committed Oct 26, 2012
1 parent a9bc598 commit 85fa6bc
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
Expand Up @@ -2414,7 +2414,9 @@ public Map getSqlFunctions() {
}

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() {
Expand Down
Expand Up @@ -598,7 +598,9 @@ protected void registerHibernateType(int code, String name) {
// 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 );
}

/**
Expand Down
Expand Up @@ -38,7 +38,6 @@ public SQLFunctionRegistry(Dialect dialect, Map<String, SQLFunction> userFunctio
}

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
Expand All @@ -47,7 +46,6 @@ public SQLFunction findSQLFunction(String functionName) {
}

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 );
}
Expand Down
Expand Up @@ -361,7 +361,7 @@ public AssociationType getElementAssociationType(CollectionType collectionType)
* @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 );
}

/**
Expand Down

0 comments on commit 85fa6bc

Please sign in to comment.