[Rt-commit] r3861 - in Jifty-DBI/trunk: . lib/Jifty/DBI t

jesse at bestpractical.com jesse at bestpractical.com
Sun Sep 18 00:39:05 EDT 2005


Author: jesse
Date: Sun Sep 18 00:39:04 2005
New Revision: 3861

Modified:
   Jifty-DBI/trunk/   (props changed)
   Jifty-DBI/trunk/lib/Jifty/DBI/Record.pm
   Jifty-DBI/trunk/t/01records.t
Log:
 r15793 at hualien:  jesse | 2005-09-18 00:38:25 -0400
 * now that it works, remove the old routine
 


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	Sun Sep 18 00:39:04 2005
@@ -825,62 +825,6 @@
     return (1);
 }
 
-=head2 truncate_value  COLUMN VALUE
-
-Truncate a value that's about to be set so that it will fit inside the
-database' s idea of how big the column is.
-
-(Actually, it looks at L<Jifty::DBI>'s concept of the database, not
-directly into the db).
-
-=cut
-
-sub truncate_value {
-    my $self  = shift;
-    my $column_name   = shift;
-    my $value = shift;
-
-    # We don't need to truncate empty things.
-    return undef unless ( defined($value) ); 
-
-    my $column = $self->column($column_name);
-
-    die "No column $column_name" unless ($column);
-
-    my $truncate_to;
-    if ( $column->length && !$column->is_numeric ) {
-        $truncate_to = $column->length;
-    }
-    elsif ( $column->type && $column->type =~ /char\((\d+)\)/ ) {
-        $truncate_to = $1;
-    }
-
-    return ($value) unless ($truncate_to);    # don't need to truncate
-
-    # Perl 5.6 didn't speak unicode
-    return substr( $value, 0, $truncate_to ) unless ( $] >= 5.007 );
-
-    require Encode;
-
-    if ( Encode::is_utf8($value) ) {
-        return Encode::decode(
-            utf8 =>
-                substr( Encode::encode( utf8 => $value ), 0, $truncate_to ),
-            Encode::FB_QUIET(),
-        );
-    }
-    else {
-        return Encode::encode(
-            utf8 => Encode::decode(
-                utf8 => substr( $value, 0, $truncate_to ),
-                Encode::FB_QUIET(),
-            )
-        );
-
-    }
-
-}
-
 =head2 load
 
 Takes a single argument, $id. Calls load_by_cols to retrieve the row whose primary key
@@ -1052,9 +996,6 @@
 
         $column->encode_value( \$attribs{$column_name});
 
-        #Truncate things that are too long for their datatypes
-        $attribs{$column_name} = $self->truncate_value( $column_name => $attribs{$column_name} );
-
     }
     unless ( $self->_handle->knows_blobs ) {
         # Support for databases which don't deal with LOBs automatically

Modified: Jifty-DBI/trunk/t/01records.t
==============================================================================
--- Jifty-DBI/trunk/t/01records.t	(original)
+++ Jifty-DBI/trunk/t/01records.t	Sun Sep 18 00:39:04 2005
@@ -8,7 +8,7 @@
 BEGIN { require "t/utils.pl" }
 our (@available_drivers);
 
-use constant TESTS_PER_DRIVER => 64;
+use constant TESTS_PER_DRIVER => 63;
 
 my $total = scalar(@available_drivers) * TESTS_PER_DRIVER;
 plan tests => $total;
@@ -78,8 +78,6 @@
 	($val,$msg) = $rec->set_name('1234567890123456789012345678901234567890');
 	ok($val, $msg);
 	is($rec->name, '12345678901234', "Truncated on update");
-	$val = $rec->truncate_value(phone => '12345678901234567890');
-	is($val, '123456789012345678', 'truncate by length attribute');
 
 
 # Test unicode truncation:


More information about the Rt-commit mailing list