aboutsummaryrefslogtreecommitdiffstats
path: root/container-search/src/test
diff options
context:
space:
mode:
authorTor Egge <Tor.Egge@online.no>2023-11-29 14:22:13 +0100
committerTor Egge <Tor.Egge@online.no>2023-11-29 14:22:13 +0100
commit89f5b616f391124a8fbb6d2e9c4e8c4d32b91efa (patch)
treed5a12879a055a6ae3344b742b9dbdbbd1450f8f0 /container-search/src/test
parent3b5afd56981156cb608718925fcd55f9d7e38845 (diff)
Limit yql in operator to string and integer fields.
Diffstat (limited to 'container-search/src/test')
-rw-r--r--container-search/src/test/java/com/yahoo/search/yql/VespaSerializerTestCase.java4
-rw-r--r--container-search/src/test/java/com/yahoo/search/yql/YqlParserTestCase.java13
2 files changed, 12 insertions, 5 deletions
diff --git a/container-search/src/test/java/com/yahoo/search/yql/VespaSerializerTestCase.java b/container-search/src/test/java/com/yahoo/search/yql/VespaSerializerTestCase.java
index 6aac2faa4e9..87bc602f072 100644
--- a/container-search/src/test/java/com/yahoo/search/yql/VespaSerializerTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/yql/VespaSerializerTestCase.java
@@ -49,7 +49,9 @@ public class VespaSerializerTestCase {
static private IndexFacts createIndexFactsForInTest() {
SearchDefinition sd = new SearchDefinition("sourceA");
- sd.addIndex(new Index("field"));
+ Index fieldIndex = new Index("field");
+ fieldIndex.setInteger(true);
+ sd.addIndex(fieldIndex);
Index stringIndex = new Index("string");
stringIndex.setString(true);
sd.addIndex(stringIndex);
diff --git a/container-search/src/test/java/com/yahoo/search/yql/YqlParserTestCase.java b/container-search/src/test/java/com/yahoo/search/yql/YqlParserTestCase.java
index bd29e2afd53..4ea40bb45e2 100644
--- a/container-search/src/test/java/com/yahoo/search/yql/YqlParserTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/yql/YqlParserTestCase.java
@@ -82,10 +82,14 @@ public class YqlParserTestCase {
static private IndexFacts createIndexFactsForInTest() {
SearchDefinition sd = new SearchDefinition("default");
- sd.addIndex(new Index("field"));
+ Index fieldIndex = new Index("field");
+ fieldIndex.setInteger(true);
+ sd.addIndex(fieldIndex);
Index stringIndex = new Index("string");
stringIndex.setString(true);
sd.addIndex(stringIndex);
+ Index floatIndex = new Index("float");
+ sd.addIndex(floatIndex);
return new IndexFacts(new IndexModel(sd));
}
@@ -1183,10 +1187,9 @@ public class YqlParserTestCase {
parser.setUserQuery(createUserQuery());
query = parse("select * from sources * where string in ('a','b', @foostring)");
assertStringInItem("string", new String[]{"a","b","might","this", "work"}, query);
- parser.setUserQuery(createUserQuery());
- query = parse("select * from sources * where field in (29.9, -7.4)");
- assertNumericInItem("field", new long[]{-7, 29}, query);
parser.setUserQuery(null);
+ assertParseFail("select * from sources * where field in (29.9, -7.4)",
+ new ClassCastException("Cannot cast java.lang.Double to java.lang.Long"));
assertParseFail("select * from sources * where string in ('a', 25L)",
new ClassCastException("Cannot cast java.lang.Long to java.lang.String"));
assertParseFail("select * from sources * where field in ('a', 25L)",
@@ -1195,6 +1198,8 @@ public class YqlParserTestCase {
new IllegalArgumentException("Field 'nofield' does not exist."));
assertParseFail("select * from sources * where field not in (25)",
new IllegalArgumentException("Expected AND, CALL, CONTAINS, EQ, GT, GTEQ, IN, LT, LTEQ or OR, got NOT_IN."));
+ assertParseFail("select * from sources * where float in (25)",
+ new IllegalArgumentException("index float is not an integer or string field"));
}
private static void assertNumericInItem(String field, long[] values, QueryTree query) {