mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-10-24 15:55:55 +00:00
#565 - Query plan hash collision on firstRow/maxRows combinations - tests
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
package com.avaje.ebeaninternal.api;
|
||||
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class HashQueryPlanBuilderTest {
|
||||
|
||||
int combine(int v0, int v1) {
|
||||
return new HashQueryPlanBuilder().add(v0).add(v1).build().hashCode();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_pair_0_1() {
|
||||
assertThat(combine(0, 31)).isNotEqualTo(combine(1,0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_pair_0_10_adjust_0() {
|
||||
assertThat(combine(0, 310)).isNotEqualTo(combine(10,0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_pair_0_10_adjust_10() {
|
||||
assertThat(combine(0, 320)).isNotEqualTo(combine(10,10));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_pair_0_10_adjust_40() {
|
||||
assertThat(combine(0, 350)).isNotEqualTo(combine(10,40));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_pair_0_10_adjust_90() {
|
||||
assertThat(combine(0, 400)).isNotEqualTo(combine(10,90));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -37,4 +37,28 @@ public class DefaultOrmQueryTest {
|
||||
assertThat(hash1).isNotEqualTo(hash2);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_AutofetchHash_diffFirstRows() throws Exception {
|
||||
|
||||
SpiQuery<?> query1 = (SpiQuery<?>)Ebean.find(Order.class)
|
||||
.setFirstRow(0)
|
||||
.setMaxRows(31);
|
||||
|
||||
HashQueryPlanBuilder b1 = new HashQueryPlanBuilder();
|
||||
query1.queryAutoTuneHash(b1);
|
||||
HashQueryPlan hash1 = b1.build();
|
||||
|
||||
SpiQuery<?> query2 = (SpiQuery<?>)Ebean.find(Order.class)
|
||||
.setFirstRow(1)
|
||||
.setMaxRows(0);
|
||||
|
||||
HashQueryPlanBuilder b2 = new HashQueryPlanBuilder();
|
||||
query2.queryAutoTuneHash(b2);
|
||||
HashQueryPlan hash2 = b2.build();
|
||||
|
||||
assertThat(hash1).isNotEqualTo(hash2);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user