[freeside-commits] branch master updated. b853ec09fb19df91fe0188c5dde9d759333a2503

Carl J. Adams-Collier cjac at 420.am
Mon Sep 8 13:51:06 PDT 2014


The branch, master has been updated
       via  b853ec09fb19df91fe0188c5dde9d759333a2503 (commit)
      from  61c4e7640f905d326b36e61ad3ce81d22a9a663a (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit b853ec09fb19df91fe0188c5dde9d759333a2503
Author: C.J. Adams-Collier <cjac at colliertech.org>
Date:   Mon Sep 8 13:25:10 2014 -0700

    ensuring that WHERE or AND is correctly used in "$extra_sql" snippit - FS RT #884

diff --git a/FS/FS/Record.pm b/FS/FS/Record.pm
index 8f75734..1b7ac8a 100644
--- a/FS/FS/Record.pm
+++ b/FS/FS/Record.pm
@@ -402,13 +402,31 @@ sub qsearch {
         get_real_fields($table, $record, \@real_fields));
     }
 
-    $statement .= " $extra_sql" if defined($extra_sql);
+    if( defined($extra_sql) ){
+      if( $statement =~ /\sWHERE\s/i ){
+	if( $extra_sql =~ /^\s*AND /i ){
+	  # correct format
+	}elsif($extra_sql =~ /^\s*WHERE /i ){
+	  $extra_sql =~ s/WHERE /AND /i;
+	}else{
+	  $extra_sql = " AND $extra_sql";
+	}
+      }else{
+	if( $extra_sql =~ /^\s*AND /i ){
+	  $extra_sql =~ s/AND /WHERE /i;
+	}elsif($extra_sql =~ /^\s*WHERE /i ){
+	  # correct format
+	}else{
+	  $extra_sql = " WHERE $extra_sql";
+	}
+      }
+      $statement .= " $extra_sql";
+    }
     $statement .= " $order_by"  if defined($order_by);
 
     push @statement, $statement;
 
     warn "[debug]$me $statement\n" if $DEBUG > 1 || $debug;
- 
 
     foreach my $field (
       grep defined( $record->{$_} ) && $record->{$_} ne '', @real_fields

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

Summary of changes:
 FS/FS/Record.pm |   22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)




More information about the freeside-commits mailing list