mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Refactor SpiExpressionRequest split parse() into property() and path() to have fast path
property() uses a fast path for the common case that the expression is a bean property path. This will then fall back to using parse() when that isn't the case.
This commit is contained in:
@@ -26,11 +26,13 @@ public class DeployPropertyParserTest extends BaseTest {
|
||||
|
||||
@Test
|
||||
public void depth1_path() {
|
||||
Assertions.assertThat(parser().property("billingAddress.city")).isEqualTo("${billingAddress}city");
|
||||
Assertions.assertThat(parser().parse("billingAddress.city")).isEqualTo("${billingAddress}city");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void depth2_path() {
|
||||
Assertions.assertThat(parser().property("max(billingAddress.country.name)")).isEqualTo("max(${billingAddress.country}name)");
|
||||
Assertions.assertThat(parser().parse("max(billingAddress.country.name)")).isEqualTo("max(${billingAddress.country}name)");
|
||||
}
|
||||
|
||||
@@ -69,6 +71,7 @@ public class DeployPropertyParserTest extends BaseTest {
|
||||
|
||||
@Test
|
||||
public void unknown_path() {
|
||||
Assertions.assertThat(parser().property(" foo ")).isEqualTo(" foo ");
|
||||
Assertions.assertThat(parser().parse(" foo ")).isEqualTo(" foo ");
|
||||
}
|
||||
|
||||
|
||||
+8
-2
@@ -44,8 +44,14 @@ public class TDSpiExpressionRequest implements SpiExpressionRequest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpiExpressionRequest append(String sqlExpression) {
|
||||
sql.append(sqlExpression);
|
||||
public SpiExpressionRequest append(String expression) {
|
||||
sql.append(expression);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpiExpressionRequest property(String expression) {
|
||||
sql.append(expression);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user