[Rt-commit] rt branch, 4.2/autocomplete-links, updated. rt-3.9.7-1169-g30c9344

Shawn Moore sartak at bestpractical.com
Thu Mar 10 12:15:32 EST 2011


The branch, 4.2/autocomplete-links has been updated
       via  30c9344087111a50739c8df6cba960103c91f97e (commit)
      from  49f7d13f3d945f1bddeace1ae2db5502695829fc (commit)

Summary of changes:
 lib/RT/Tickets.pm |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

- Log -----------------------------------------------------------------
commit 30c9344087111a50739c8df6cba960103c91f97e
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Thu Mar 10 12:13:39 2011 -0500

    Support limiting int ticket fields by LIKE on Postgres

diff --git a/lib/RT/Tickets.pm b/lib/RT/Tickets.pm
index b79ca81..13bbaea 100644
--- a/lib/RT/Tickets.pm
+++ b/lib/RT/Tickets.pm
@@ -389,6 +389,21 @@ Meta Data:
 sub _IntLimit {
     my ( $sb, $field, $op, $value, @rest ) = @_;
 
+    my $is_a_like = $op =~ /MATCHES|ENDSWITH|STARTSWITH|LIKE/;
+
+    # We want to support <id LIKE '1%'> for ticket autocomplete,
+    # but we need to explicitly typecast on Postgres
+    if ( $is_a_like && RT->Config->Get('DatabaseType') eq 'Pg' ) {
+        return $sb->_SQLLimit(
+            # XXX: Nasty hack
+            ALIAS    => 'CAST( main',
+            FIELD    => $field . ' AS TEXT)',
+            OPERATOR => $op,
+            VALUE    => $value,
+            @rest,
+        );
+    }
+
     $sb->_SQLLimit(
         FIELD    => $field,
         VALUE    => $value,

-----------------------------------------------------------------------


More information about the Rt-commit mailing list