From 2cb6d101114ca0fb1a95fc8e3b30b0caa9831a83 Mon Sep 17 00:00:00 2001 From: Lebbeous Fogle-Weekley Date: Thu, 17 Oct 2013 12:49:52 -0400 Subject: [PATCH] In search, do create_date/edit_date comparisons by date, not timestamp This makes searches on a date range include whole days at the start and end of the range, whereas before they excluded the day at the end of the range. Signed-off-by: Lebbeous Fogle-Weekley --- .../lib/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm index e4e237c035..64128c1c44 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm @@ -1136,8 +1136,9 @@ sub flatten { } else { # "before $cend" $cend = cleanse_ISO8601($cend); + $cend =~ s/^(.+)T.+$/$1/; $where .= $joiner if $where ne ''; - $where .= "bre.$datefilter <= \$_$$\$$cend\$_$$\$"; + $where .= "bre.$datefilter\::DATE <= \$_$$\$$cend\$_$$\$"; } } elsif (!$cend or $cend eq 'infinity') { # no end supplied @@ -1145,15 +1146,18 @@ sub flatten { # useless use of filter } else { # "after $cstart" $cstart = cleanse_ISO8601($cstart); + $cstart =~ s/^(.+)T.+$/$1/; $where .= $joiner if $where ne ''; - $where .= "bre.$datefilter >= \$_$$\$$cstart\$_$$\$"; + $where .= "bre.$datefilter\::DATE >= \$_$$\$$cstart\$_$$\$"; } } else { # both supplied # "between $cstart and $cend" $cstart = cleanse_ISO8601($cstart); $cend = cleanse_ISO8601($cend); + $cstart =~ s/^(.+)T.+$/$1/; + $cend =~ s/^(.+)T.+$/$1/; $where .= $joiner if $where ne ''; - $where .= "bre.$datefilter BETWEEN \$_$$\$$cstart\$_$$\$ AND \$_$$\$$cend\$_$$\$"; + $where .= "bre.$datefilter\::DATE BETWEEN \$_$$\$$cstart\$_$$\$ AND \$_$$\$$cend\$_$$\$"; } } } elsif ($filter->name eq 'bib_source') { -- 2.11.0