[#240,bugfix,backend/memory][s]: range filters now work as expected when one end of range is null - fixes #240.

* see ticket and comments for more details
This commit is contained in:
Rufus Pollock
2012-10-12 22:29:55 +01:00
parent 7819b3b185
commit 046ee8c1a0
2 changed files with 44 additions and 1 deletions

View File

@@ -134,12 +134,19 @@ this.recline.Backend.Memory = this.recline.Backend.Memory || {};
}
function range(record, filter) {
var startnull = (filter.start == null || filter.start === '');
var stopnull = (filter.stop == null || filter.stop === '');
var parse = getDataParser(filter);
var value = parse(record[filter.field]);
var start = parse(filter.start);
var stop = parse(filter.stop);
return (value >= start && value <= stop);
// if at least one end of range is set do not allow '' to get through
// note that for strings '' <= {any-character} e.g. '' <= 'a'
if ((!startnull || !stopnull) && value === '') {
return false;
}
return ((startnull || value >= start) && (stopnull || value <= stop));
}
function geo_distance() {