Skip to content
Snippets Groups Projects
Commit 37b18801 authored by Daniel Hornung's avatar Daniel Hornung
Browse files

ENH: Always apply POV to ints and doubles alike.

parent 0c329e01
No related branches found
No related tags found
2 merge requests!66REL: prepare release 0.8.0,!62Fix large integer queries
......@@ -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();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment