[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SF.net SVN: ledger-smb:[5014] trunk/LedgerSMB



Revision: 5014
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=5014&view=rev
Author:   einhverfr
Date:     2012-07-18 08:38:50 +0000 (Wed, 18 Jul 2012)
Log Message:
-----------
Moved from manual to automatic checking for byteas

Modified Paths:
--------------
    trunk/LedgerSMB/DBObject.pm
    trunk/LedgerSMB/Scripts/file.pm

Modified: trunk/LedgerSMB/DBObject.pm
===================================================================
--- trunk/LedgerSMB/DBObject.pm	2012-07-18 07:41:00 UTC (rev 5013)
+++ trunk/LedgerSMB/DBObject.pm	2012-07-18 08:38:50 UTC (rev 5014)
@@ -106,6 +106,7 @@
 }
 
 sub exec_method {
+    use DBD::Pg qw(:pg_types);
     my $self   = shift @_;
     my %args  = (ref($_[0]) eq 'HASH')? %{$_[0]}: @_;
     my $funcname = $args{funcname};
@@ -120,7 +121,7 @@
     my @call_args;
      
     my $query = "
-	SELECT proname, pronargs, proargnames FROM pg_proc 
+	SELECT proname, pronargs, proargnames, proargtypes FROM pg_proc 
 	 WHERE proname = ? 
 	       AND pronamespace = 
 	       coalesce((SELECT oid FROM pg_namespace WHERE nspname = ?), 
@@ -137,6 +138,7 @@
     
     my $pargs = $ref->{proargnames};
     my @proc_args;
+    my @proargtypes = split / /, $ref->{proargtypes};
 
     if ( !$ref->{proname} ) {    # no such function
         # If the function doesn't exist, $funcname gets zeroed?
@@ -149,6 +151,7 @@
         @proc_args = $self->_parse_array($pargs);
         if (@proc_args) {
             for my $arg (@proc_args) {
+                my $atype = shift @proargtypes;
                 #print STDERR "User Provided Args: $arg\n";
                 if ( $arg =~ s/^in_// ) {
                      if ( defined $self->{$arg} )
@@ -160,7 +163,12 @@
                         $logger->debug("exec_method pushing \$arg defined $arg | \$self->{\$arg} is undefined");
                         #$self->{$arg} = undef; # Why was this being unset? --CT
                      }
-                     push ( @call_args, $self->{$arg} );
+                     if ($atype == 17){
+                         push ( @call_args, { value => $self->{$arg} ,
+                                               type => DBD::Pg::PG_BYTEA });
+                     } else {    
+                         push ( @call_args, $self->{$arg} );
+                     }
                 }
             }
         }

Modified: trunk/LedgerSMB/Scripts/file.pm
===================================================================
--- trunk/LedgerSMB/Scripts/file.pm	2012-07-18 07:41:00 UTC (rev 5013)
+++ trunk/LedgerSMB/Scripts/file.pm	2012-07-18 08:38:50 UTC (rev 5014)
@@ -112,7 +112,7 @@
         $file->get_mime_type;
         my $fh = $request->{_request}->upload('upload_data');
         my $fdata = join ("", <$fh>);
-        $file->content({value => $fdata, type => => DBD::Pg::PG_BYTEA});
+        $file->content($fdata);
     }
     $request->{content} = $file->content;
     $file->attach;

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.