mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#291 - ENH: Add ability to validate a query or property expression - Was Please check column exist on entity
This commit is contained in:
@@ -26,6 +26,13 @@ public class SpiServerTest {
|
||||
assertNull(beanType.getPersistListener());
|
||||
assertNull(beanType.getQueryAdapter());
|
||||
|
||||
assertTrue(beanType.isValidExpression("name"));
|
||||
assertTrue(beanType.isValidExpression("contacts.firstName"));
|
||||
assertTrue(beanType.isValidExpression("contacts.group.name"));
|
||||
assertFalse(beanType.isValidExpression("junk"));
|
||||
assertFalse(beanType.isValidExpression("Name"));
|
||||
assertFalse(beanType.isValidExpression("contacts.name"));
|
||||
|
||||
Customer customer = new Customer();
|
||||
customer.setId(42);
|
||||
|
||||
|
||||
@@ -292,6 +292,11 @@ public class TDSpiEbeanServer implements SpiEbeanServer {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Set<String> validateQuery(Query<T> query) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object nextId(Class<?> beanType) {
|
||||
return null;
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
package com.avaje.tests.query.orderby;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.avaje.tests.model.basic.Customer;
|
||||
import com.avaje.tests.model.basic.ResetBasicData;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -12,9 +15,29 @@ import com.avaje.tests.model.basic.MRole;
|
||||
import com.avaje.tests.model.basic.MUser;
|
||||
import com.avaje.tests.model.basic.MUserType;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
||||
public class TestOrderByWithDistinct extends BaseTestCase {
|
||||
|
||||
|
||||
@Test
|
||||
public void testOrderByValidation() {
|
||||
|
||||
ResetBasicData.reset();
|
||||
|
||||
Query<Customer> query = Ebean.find(Customer.class)
|
||||
.where()
|
||||
.eq("junk","blah")
|
||||
.eq("name","jim")
|
||||
.orderBy("id desc,path.that.does.not.exist,contacts.group.name asc");
|
||||
|
||||
Set<String> unknownProperties = query.validate();
|
||||
assertThat(unknownProperties).isNotEmpty();
|
||||
assertThat(unknownProperties).hasSize(2);
|
||||
assertThat(unknownProperties).contains("junk","path.that.does.not.exist");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user