In search, do create_date/edit_date comparisons by date, not timestamp collab/senator/bre_dates_not_timestamps
authorLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Thu, 17 Oct 2013 16:49:52 +0000 (12:49 -0400)
committerLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Thu, 17 Oct 2013 17:05:36 +0000 (13:05 -0400)
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 <lebbeous@esilibrary.com>
Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm

index e4e237c..64128c1 100644 (file)
@@ -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') {