[hibernate-dev] Storing SQL keywords in lowercase

Vlad Mihalcea mihalcea.vlad at gmail.com
Thu May 19 01:01:31 EDT 2016


Hi,

I tested and want to integrate this PR:

https://github.com/hibernate/hibernate-orm/pull/1011

However, there is this change in the Dialect class that seems reasonable,
but wanted to confirm that it will no break anything:

protected void registerKeyword(String word) {
    // When tokens are checked for keywords, they are always compared to
the lower-case version of the token.
    // Ex: INTEGER is always compared as integer. This can lead to
incorrect behaviour when registering custom keywords
    // that are then used in formulas, as it is not made apparent that
formula query generation always looks at
    // the lower-case token.
    sqlKeywords.add(word.toLowerCase(Locale.ROOT));
}

For SQL functions, we do something similar:

protected void registerFunction(String name, SQLFunction function) {
   // HHH-7721: SQLFunctionRegistry expects all lowercase.  Enforce,
   // just in case a user's customer dialect uses mixed cases.
   sqlFunctions.put( name.toLowerCase( Locale.ROOT ), function );
}

This should be the right thing to do considering that
org.hibernate.sql.Template uses a lower case token as well:

String lcToken = token.toLowerCase(Locale.ROOT);

I see that only CUBRID and Derby Dialects register UPPERCASE keywords, so
I'm going to test it on Derby to see how it works.

Does anyone think that this change is going to break something in other
some other part which I might not be aware of?

Vlad


More information about the hibernate-dev mailing list