-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
SpEL template behavior is inconsistent [DATAJPA-1266] #1597
Comments
Oliver Drotbohm commented I guess we need to:
If we can trigger 2 without masking the SpEL-based bind variables to be handled in 1, we can also flip the steps, should that make things easier |
I have re-input @schauder 's original test cases and run them through the latest-and-greatest of Spring Data JPA, parser and all. Can either @schauder or @odrotbohm verify that this is the desired final results? If so, I'll add these test cases and push to @Test
public void doesTemplatingWhenEntityNameSpelIsPresent() {
StringQuery query = new ExpressionBasedStringQuery("select #{#entityName + 'Hallo'} from #{#entityName} u",
metadata, SPEL_PARSER, false);
assertThat(query.getQueryString()).isEqualTo("select UserHallo from User u");
}
@Test
public void doesNoTemplatingWhenEntityNameSpelIsNotPresent() {
StringQuery query = new ExpressionBasedStringQuery("select #{#entityName + 'Hallo'} from User u", metadata,
SPEL_PARSER, false);
assertThat(query.getQueryString()).isEqualTo("select #{#entityName + 'Hallo'} from User u");
}
@Test
public void doesTemplatingWhenEntityNameSpelIsPresentForBindParameter() {
StringQuery query = new ExpressionBasedStringQuery("select u from #{#entityName} u where name = :#{#something}",
metadata, SPEL_PARSER, false);
assertThat(query.getQueryString()).isEqualTo("select u from User u where name = :__$synthetic$__1");
} |
I think the second should be |
Merged to |
Jens Schauder opened DATAJPA-1266 and commented
The following tests succeed when added to
ExpressionBasedStringQueryUnitTests
We only apply templating if
#\{#entityName\
} is present in the query string. If we do so, we use the full-blown SpEL templating mechanism, i.e also other SpEL expressions get evaluated and replaced.Also, SpEL expressions for bind parameters only get protected from this when they start with
?#
not when they start with:#
No further details from DATAJPA-1266
The text was updated successfully, but these errors were encountered: