[Jifty-commit] r931 - in Jifty-DBI/trunk: . lib/Jifty/DBI

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Wed Apr 26 14:35:38 EDT 2006


Author: alexmv
Date: Wed Apr 26 14:35:32 2006
New Revision: 931

Modified:
   Jifty-DBI/trunk/   (props changed)
   Jifty-DBI/trunk/lib/Jifty/DBI/Handle.pm
   Jifty-DBI/trunk/lib/Jifty/DBI/Handle/Oracle.pm
   Jifty-DBI/trunk/lib/Jifty/DBI/Handle/Pg.pm
   Jifty-DBI/trunk/lib/Jifty/DBI/Handle/SQLite.pm
   Jifty-DBI/trunk/lib/Jifty/DBI/Handle/Sybase.pm
   Jifty-DBI/trunk/lib/Jifty/DBI/Record.pm

Log:
 r12629 at zoq-fot-pik:  chmrr | 2006-04-26 14:32:48 -0400
  * Make Postgres support BLOBs
  * Remove old knows_blobs and binary_safe_blobs flags


Modified: Jifty-DBI/trunk/lib/Jifty/DBI/Handle.pm
==============================================================================
--- Jifty-DBI/trunk/lib/Jifty/DBI/Handle.pm	(original)
+++ Jifty-DBI/trunk/lib/Jifty/DBI/Handle.pm	Wed Apr 26 14:35:32 2006
@@ -507,34 +507,10 @@
     }
 }
 
-=head2 binary_safe_blobs
+=head2 blob_params COLUMN_NAME COLUMN_TYPE
 
-Returns 1 if the current database supports BLOBs with embedded nulls.
-Returns undef if the current database doesn't support BLOBs with embedded nulls
-
-=cut
-
-sub binary_safe_blobs {
-    my $self = shift;
-    return (1);
-}
-
-=head2 knows_blobs
-
-Returns 1 if the current database supports inserts of BLOBs automatically.
-Returns undef if the current database must be informed of BLOBs for inserts.
-
-=cut
-
-sub knows_blobs {
-    my $self = shift;
-    return (1);
-}
-
-=head2 blob_params column_NAME column_type
-
-Returns a hash ref for the bind_param call to identify BLOB types used by 
-the current database for a particular column type.                 
+Returns a hash ref for the bind_param call to identify BLOB types used
+by the current database for a particular column type.
 
 =cut
 

Modified: Jifty-DBI/trunk/lib/Jifty/DBI/Handle/Oracle.pm
==============================================================================
--- Jifty-DBI/trunk/lib/Jifty/DBI/Handle/Oracle.pm	(original)
+++ Jifty-DBI/trunk/lib/Jifty/DBI/Handle/Oracle.pm	Wed Apr 26 14:35:32 2006
@@ -148,19 +148,6 @@
     $self->{'dsn'} = $dsn;
 }
 
-=head2 knows_blobs     
-
-Returns 1 if the current database supports inserts of BLOBs
-automatically.  Returns undef if the current database must be informed
-of BLOBs for inserts.
-
-=cut
-
-sub knows_blobs {
-    my $self = shift;
-    return (undef);
-}
-
 =head2 blob_params column_NAME column_type
 
 Returns a hash ref for the bind_param call to identify BLOB types used
@@ -173,7 +160,6 @@
     my $self   = shift;
     my $column = shift;
 
-    #my $type = shift;
     # Don't assign to key 'value' as it is defined later.
     return (
         {   ora_column => $column,
@@ -272,17 +258,6 @@
     }
 }
 
-=head2 binary_safe_blobs
-
-Return undef, as Oracle doesn't support binary-safe CLOBS
-
-=cut
-
-sub binary_safe_blobs {
-    my $self = shift;
-    return (undef);
-}
-
 1;
 
 __END__

Modified: Jifty-DBI/trunk/lib/Jifty/DBI/Handle/Pg.pm
==============================================================================
--- Jifty-DBI/trunk/lib/Jifty/DBI/Handle/Pg.pm	(original)
+++ Jifty-DBI/trunk/lib/Jifty/DBI/Handle/Pg.pm	Wed Apr 26 14:35:32 2006
@@ -111,16 +111,22 @@
 
 }
 
-=head2 binary_safe_blobs
+=head2 blob_params column_NAME column_type
 
-Return undef, as no current version of postgres supports binary-safe
-blobs
+Returns a hash ref for the bind_param call to identify BLOB types used
+by the current database for a particular column type.  The current
+Postgres implementation only supports BYTEA types.
 
 =cut
 
-sub binary_safe_blobs {
-    my $self = shift;
-    return (undef);
+sub blob_params {
+    my $self   = shift;
+    my $name = shift;
+    my $type = shift;
+
+    # Don't assign to key 'value' as it is defined later.
+    return ( { pg_type => DBD::Pg::PG_BYTEA() } ) if $type eq "blob";
+    return ( {} );
 }
 
 =head2 apply_limits STATEMENTREF ROWS_PER_PAGE FIRST_ROW

Modified: Jifty-DBI/trunk/lib/Jifty/DBI/Handle/SQLite.pm
==============================================================================
--- Jifty-DBI/trunk/lib/Jifty/DBI/Handle/SQLite.pm	(original)
+++ Jifty-DBI/trunk/lib/Jifty/DBI/Handle/SQLite.pm	Wed Apr 26 14:35:32 2006
@@ -71,10 +71,6 @@
     return (1);
 }
 
-sub binary_safe_blobs {
-    return undef;
-}
-
 =head2 distinct_count STATEMENTREF
 
 takes an incomplete SQL SELECT statement and massages it to return a DISTINCT result count

Modified: Jifty-DBI/trunk/lib/Jifty/DBI/Handle/Sybase.pm
==============================================================================
--- Jifty-DBI/trunk/lib/Jifty/DBI/Handle/Sybase.pm	(original)
+++ Jifty-DBI/trunk/lib/Jifty/DBI/Handle/Sybase.pm	Wed Apr 26 14:35:32 2006
@@ -115,18 +115,6 @@
     $$statementref .= $sb->_order_clause;
 }
 
-=head2 binary_safe_blobs
-
-Return undef, as Oracle doesn't support binary-safe CLOBS
-
-
-=cut
-
-sub binary_safe_blobs {
-    my $self = shift;
-    return (undef);
-}
-
 1;
 
 __END__

Modified: Jifty-DBI/trunk/lib/Jifty/DBI/Record.pm
==============================================================================
--- Jifty-DBI/trunk/lib/Jifty/DBI/Record.pm	(original)
+++ Jifty-DBI/trunk/lib/Jifty/DBI/Record.pm	Wed Apr 26 14:35:32 2006
@@ -571,19 +571,14 @@
         return ( $ret->return_value );
     }
 
-    # The blob handling will destroy $args{'Value'}. But we assign
+    # The blob handling will destroy $args{'value'}. But we assign
     # that back to the object at the end. this works around that
     my $unmunged_value = $args{'value'};
 
-    unless ( $self->_handle->knows_blobs ) {
-
-        # Support for databases which don't deal with LOBs automatically
-        if ( $column->type =~ /^(text|longtext|clob|blob|lob)$/i ) {
-            my $bhash
-                = $self->_handle->blob_params( $column->name, $column->type );
-            $bhash->{'value'} = $args{'value'};
-            $args{'value'} = $bhash;
-        }
+    if ( $column->type =~ /^(text|longtext|clob|blob|lob|bytea)$/i ) {
+        my $bhash = $self->_handle->blob_params( $column->name, $column->type );
+        $bhash->{'value'} = $args{'value'};
+        $args{'value'} = $bhash;
     }
 
     my $val = $self->_handle->update_record_value(
@@ -612,7 +607,7 @@
         # XXX TODO primary_keys
         $self->load_by_cols( id => $self->id );
     } else {
-        $self->{'values'}->{ $column->name } = $unmunged_value;
+        $self->{'values'}{ $column->name } = $unmunged_value;
         $self->{'decoded'}{ $column->name } = 0;
     }
     $ret->as_array( 1, "The new value has been set." );
@@ -847,18 +842,10 @@
             value_ref => \$attribs{$column_name},
         );
 
-    }
-    unless ( $self->_handle->knows_blobs ) {
-
-        # Support for databases which don't deal with LOBs automatically
-        foreach my $column_name ( keys %attribs ) {
-            my $column = $self->column($column_name);
-            if ( $column->type =~ /^(text|longtext|clob|blob|lob)$/i ) {
-                my $bhash = $self->_handle->blob_params( $column_name,
-                    $column->type );
-                $bhash->{'value'} = $attribs{$column_name};
-                $attribs{$column_name} = $bhash;
-            }
+        if ( $column->type =~ /^(text|longtext|clob|blob|lob|bytea)$/i ) {
+            my $bhash = $self->_handle->blob_params( $column_name, $column->type );
+            $bhash->{'value'} = $attribs{$column_name};
+            $attribs{$column_name} = $bhash;
         }
     }
     my $ret = $self->_handle->insert( $self->table, %attribs );


More information about the Jifty-commit mailing list