Enforce at least one bound != null for NumericRangeQuery to be consistent with other range query types

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@788295 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Uwe Schindler 2009-06-25 08:51:12 +00:00
parent 5f61172464
commit 1e61831f8a
3 changed files with 2 additions and 2 deletions

View File

@ -127,6 +127,8 @@ public final class NumericRangeQuery extends MultiTermQuery {
Number min, Number max, final boolean minInclusive, final boolean maxInclusive
) {
assert (valSize == 32 || valSize == 64);
if (min == null && max == null)
throw new IllegalArgumentException("At least one value must be non-null");
if (precisionStep < 1 || precisionStep > valSize)
throw new IllegalArgumentException("precisionStep may only be 1.."+valSize);
this.field = field.intern();

View File

@ -385,7 +385,6 @@ public class TestNumericRangeQuery32 extends LuceneTestCase {
QueryUtils.checkHashEquals(NumericRangeQuery.newIntRange("test4", 4, new Integer(10), new Integer(20), false, false));
QueryUtils.checkHashEquals(NumericRangeQuery.newIntRange("test5", 4, new Integer(10), null, true, true));
QueryUtils.checkHashEquals(NumericRangeQuery.newIntRange("test6", 4, null, new Integer(20), true, true));
QueryUtils.checkHashEquals(NumericRangeQuery.newIntRange("test7", 4, null, null, true, true));
QueryUtils.checkEqual(
NumericRangeQuery.newIntRange("test8", 4, new Integer(10), new Integer(20), true, true),
NumericRangeQuery.newIntRange("test8", 4, new Integer(10), new Integer(20), true, true)

View File

@ -385,7 +385,6 @@ public class TestNumericRangeQuery64 extends LuceneTestCase {
QueryUtils.checkHashEquals(NumericRangeQuery.newLongRange("test4", 4, new Long(10L), new Long(20L), false, false));
QueryUtils.checkHashEquals(NumericRangeQuery.newLongRange("test5", 4, new Long(10L), null, true, true));
QueryUtils.checkHashEquals(NumericRangeQuery.newLongRange("test6", 4, null, new Long(20L), true, true));
QueryUtils.checkHashEquals(NumericRangeQuery.newLongRange("test7", 4, null, null, true, true));
QueryUtils.checkEqual(
NumericRangeQuery.newLongRange("test8", 4, new Long(10L), new Long(20L), true, true),
NumericRangeQuery.newLongRange("test8", 4, new Long(10L), new Long(20L), true, true)