diff --git a/src/main/java/org/caosdb/server/query/POV.java b/src/main/java/org/caosdb/server/query/POV.java index 62ad1aa770abf639f091711754f7da8df71006d3..ae1ac7055fd7734c8e8e1911c011cd528ab118bb 100644 --- a/src/main/java/org/caosdb/server/query/POV.java +++ b/src/main/java/org/caosdb/server/query/POV.java @@ -128,10 +128,8 @@ public class POV implements EntityFilterInterface { this.vInt = null; } - // try and parse as double - if (this.vInt != null) { - this.vDouble = (double) this.vInt; - } else { + // Try and parse as double, if integer parsing was unsuccessful. + if (this.vInt == null) { try { // Doubles are allowed without dots, for example when the integer overflows. final Pattern dp = Pattern.compile("^(-?[0-9]+(?:\\.)?(?:[0-9]+))\\s*([^-]*)$"); @@ -217,6 +215,11 @@ public class POV implements EntityFilterInterface { "Versioned queries are not supported for subqueries yet. Please file a feature request."); } final long t1 = System.currentTimeMillis(); + // Add type-converted substitutes for ints/doubles. + final Integer vIntSubst = (this.vDouble != null && this.vDouble % 1 == 0) + ? (int) Math.rint(this.vDouble) : null; + final Double vDoubleSubst = (this.vInt != null) ? (double) this.vInt : null; + try { this.connection = query.getConnection(); this.targetSet = query.getTargetSet(); @@ -270,15 +273,14 @@ public class POV implements EntityFilterInterface { } else { callPOV.setNull(6, VARCHAR); } - if (this.vInt != null) { // vInt - callPOV.setInt(7, this.vInt); - } else { - callPOV.setNull(7, INTEGER); - } - if (this.vDouble != null) { // vDouble - callPOV.setDouble(8, this.vDouble); - } else { - callPOV.setNull(8, DOUBLE); + if (this.vInt != null || this.vDouble != null) { // Some numeric + if (this.vInt != null) { + callPOV.setInt(7, this.vInt); + callPOV.setDouble(8, vDoubleSubst); + } else { + callPOV.setInt(7, vIntSubst); + callPOV.setDouble(8, this.vDouble); + } } if (this.unit != null) { final long unitSig = this.unit.getSignature();