Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug Fix - Escape Strings for entity name after JOIN keyword. #3338

Open
wants to merge 6 commits into
base: 5.6
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion hibernate-core/src/main/antlr/hql.g
Expand Up @@ -373,9 +373,11 @@ selectObject
// NOTE: This *must* begin with the "FROM" token, otherwise the sub-query rule will be ambiguous
// with the expression rule.
// Also note: after a comma weak keywords are allowed and should be treated as identifiers.
// fromJoin is prefixed with weakKeywords() ad some entities can be from domains ending in "in".
// eg musicmaster.in causing, current fix will atleast enable escaping the class path (fully qualified name)

fromClause
: FROM^ { weakKeywords(); } fromRange ( fromJoin | COMMA! { weakKeywords(); } fromRange )*
: FROM^ { weakKeywords(); } fromRange ( { weakKeywords(); } fromJoin | COMMA! { weakKeywords(); } fromRange )*
;

//## joinType:
Expand Down
Expand Up @@ -420,6 +420,19 @@ public void weakKeywords() throws TokenStreamException {
}
}
break;
case JOIN:
// Treat quoted string as ident if follows keyword join
// in.musicmaster causing issue as in is a keyword
// Any domains ending with 'in' Entities will face issues. Other bugs to be resolved later.
if (LA(2) == QUOTED_STRING) {
LT(2).setType(IDENT);
String id = unquote(LT(2).getText());
LT(2).setText(id);
if ( LOG.isDebugEnabled() ) {
LOG.debugf("weakKeywords() : new LT(2) token - %s", LT( 2 ));
}
}
break;
default:
// Case 2: The current token is after FROM and before '.'.
if ( LA( 0 ) == FROM && t != IDENT && LA( 2 ) == DOT ) {
Expand Down