diff --git a/src/main/java/org/caosdb/server/query/POV.java b/src/main/java/org/caosdb/server/query/POV.java index b1a457529a0199edcc5061110ee97e416a264fff..0bd0487989d2430b26bee1a5a2daa595521ca835 100644 --- a/src/main/java/org/caosdb/server/query/POV.java +++ b/src/main/java/org/caosdb/server/query/POV.java @@ -125,6 +125,7 @@ public class POV implements EntityFilterInterface { unitStr = m.group(2); this.vInt = Integer.parseInt(vIntStr); } catch (final NumberFormatException e) { + System.out.println("Integer exception"); this.vInt = null; } @@ -133,7 +134,8 @@ public class POV implements EntityFilterInterface { this.vDouble = (double) this.vInt; } else { try { - final Pattern dp = Pattern.compile("^(-?[0-9]+(?:\\.[0-9]+))\\s*([^-]*)$"); + final Pattern dp = Pattern.compile("^(-?[0-9]+(?:(\\.)?[0-9]+))\\s*([^-]*)$"); + // final Pattern dp = Pattern.compile("^(-?[0-9]+(?:\\.[0-9]+))\\s*([^-]*)$"); final Matcher m = dp.matcher(value); if (!m.matches()) { throw new NumberFormatException(); @@ -142,9 +144,9 @@ public class POV implements EntityFilterInterface { unitStr = m.group(2); this.vDouble = Double.parseDouble(vDoubleStr); - if (this.vDouble % 1 == 0) { - this.vInt = (int) Math.floor(this.vDouble); - } + // if (this.vDouble % 1 == 0) { + // this.vInt = (int) Math.floor(this.vDouble); + // } } catch (final NumberFormatException e) { this.vDouble = null; } @@ -505,6 +507,21 @@ public class POV implements EntityFilterInterface { return ret; } + /** Return the value type as string, for debugging puposes. */ + public String getValueType() { + if (this.vInt != null) { // vInt + System.out.println(this.vInt); + return "Integer"; + } + if (this.vDouble != null) { // vInt + return "Double"; + } + if (this.vDatetime != null) { // vInt + return "Datetime"; + } + return "String"; + } + public String getAggregate() { return this.aggregate; } diff --git a/src/test/java/org/caosdb/server/query/TestCQL.java b/src/test/java/org/caosdb/server/query/TestCQL.java index ff1be776b041490aac7c434acdee73c96a9e88f9..707462e543f412086efee094dfd5932533c16478 100644 --- a/src/test/java/org/caosdb/server/query/TestCQL.java +++ b/src/test/java/org/caosdb/server/query/TestCQL.java @@ -240,6 +240,7 @@ public class TestCQL { String queryIssue132b = "FIND ENTITY WHICH HAS BEEN CREATED TODAY BY ME"; String queryIssue134 = "SELECT pname FROM ename"; String queryIssue131 = "FIND ENTITY WITH pname = 13 €"; + String queryIssue145 = "FIND ENTITY WITH pname145 = 100000000000000000000"; // File paths /////////////////////////////////////////////////////////////// String filepath_verb01 = "/foo/"; @@ -6906,4 +6907,29 @@ public class TestCQL { assertEquals("POV(pname2,>,30)", pov1.getSubProperty().getFilter().toString()); assertEquals("POV(pname2,<,40)", pov2.getSubProperty().getFilter().toString()); } + + /** + * Integer values which are too large for Int32 + * + * <p>String queryIssue145= "FIND ENTITY WITH pname145 = 10000000000"; + */ + @Test + public void testIssue145() { + // must yield a valid value + CQLLexer lexer; + lexer = new CQLLexer(CharStreams.fromString(this.queryIssue145)); + final CommonTokenStream tokens = new CommonTokenStream(lexer); + + final CQLParser parser = new CQLParser(tokens); + final CqContext sfq = parser.cq(); + + System.out.println(sfq.toStringTree(parser)); + // assertEquals("POV(pname145,=,10000000000)", sfq.filter.toString()); + + // assert value + POV pov = ((POV) sfq.filter); + System.out.println(pov.getValue()); + // // assertEquals("10000000000", pov.getValue()); + // assertEquals("Double", pov.getValueType()); + } }