[freeside-commits] branch master updated. abb2295df3d5a81ed6482b1e18f82bf454d242e5

Ivan ivan at 420.am
Sun Aug 31 13:11:34 PDT 2014


The branch, master has been updated
       via  abb2295df3d5a81ed6482b1e18f82bf454d242e5 (commit)
      from  60dc4fe638eb9abc5a3ea92d43031dcbfeb71454 (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 abb2295df3d5a81ed6482b1e18f82bf454d242e5
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Sun Aug 31 13:11:33 2014 -0700

    fix inserts and don't generate extra noise on trailing blanks, RT#29053

diff --git a/bin/aradial-sftp_and_import b/bin/aradial-sftp_and_import
index cc2238e..b0878e2 100755
--- a/bin/aradial-sftp_and_import
+++ b/bin/aradial-sftp_and_import
@@ -157,6 +157,9 @@ foreach my $filename ( @$ls ) {
 
     my @keys = keys %dbhash;
 
+    #skip blank records
+    next unless grep defined($_), values %dbhash;
+
     $hash{'Status-Type'} = $status_type{ $hash{'Status-Type'} }
       if exists $status_type{ $hash{'Status-Type'} };
 
@@ -166,8 +169,8 @@ foreach my $filename ( @$ls ) {
 
       $dbhash{'AcctStartTime'} = $hash{'Date'};
 
-      $sql = 'INSERT INTO radacct ( ', join(',', @keys).
-             ' ) VALUES ( '. map( ' ? ', @keys ). ' )';
+      $sql = 'INSERT INTO radacct ( '. join(',', @keys).
+             ' ) VALUES ( '. join(',', map ' ? ', @keys ). ' )';
 
     } elsif ( $hash{'Status-Type'} eq 'Stop' ) {
 
@@ -194,6 +197,7 @@ foreach my $filename ( @$ls ) {
     foreach my $value ( map $dbhash{$_}, @keys ) {
       my $key = shift @keys;
       my $type = exists($bind_type{$key}) ? $bind_type{$key} : SQL_VARCHAR;
+      $value ||= 0 if $type == SQL_INTEGER;
       $sth->bind_param($p_num++, $value, $type);
     }
     foreach my $value ( @extra_values ) {

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

Summary of changes:
 bin/aradial-sftp_and_import |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)




More information about the freeside-commits mailing list