mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Follow up for #3248 - add betweenProperties on query bean
This commit is contained in:
+1
-1
@@ -81,7 +81,7 @@ final class BetweenPropertyExpression extends NonPrepareExpression {
|
||||
|
||||
@Override
|
||||
public void addSql(SpiExpressionRequest request) {
|
||||
request.append(" ?").append(BETWEEN).property(name(lowProperty)).append(" and ").property(name(highProperty));
|
||||
request.append("?").append(BETWEEN).property(name(lowProperty)).append(" and ").property(name(highProperty));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -813,6 +813,30 @@ public class QCustomerTest {
|
||||
new QContact()
|
||||
.firstName.inRangeWith(lastName, "B")
|
||||
.findList();
|
||||
|
||||
new QContact()
|
||||
.firstName.between("A", "B")
|
||||
.findList();
|
||||
}
|
||||
|
||||
@Test
|
||||
void betweenProperties() {
|
||||
var query = new QContact()
|
||||
.firstName.betweenProperties(lastName, "B");
|
||||
|
||||
query.findList();
|
||||
assertThat(query.getGeneratedSql()).contains(" where ? between t0.first_name and t0.last_name");
|
||||
}
|
||||
|
||||
@Test
|
||||
void betweenProperties_notFirstPredicate() {
|
||||
var query = new QContact()
|
||||
.lastName.isNotNull()
|
||||
.firstName.betweenProperties(lastName, "B")
|
||||
.email.isNotNull();
|
||||
|
||||
query.findList();
|
||||
assertThat(query.getGeneratedSql()).contains(" where t0.last_name is not null and ? between t0.first_name and t0.last_name and t0.email is not null");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -409,7 +409,7 @@ class EqlParserTest extends BaseTestCase {
|
||||
Query<Customer> query = parse("where 'x' between name and smallnote");
|
||||
query.findList();
|
||||
|
||||
assertSql(query).contains("where ? between t0.name and t0.smallnote");
|
||||
assertSql(query).contains("where ? between t0.name and t0.smallnote");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -418,7 +418,7 @@ class EqlParserTest extends BaseTestCase {
|
||||
query.setParameter("some", "A");
|
||||
query.findList();
|
||||
|
||||
assertSql(query).contains("where ? between t0.name and t0.smallnote");
|
||||
assertSql(query).contains("where ? between t0.name and t0.smallnote");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user