[Jifty-commit] r2572 - in Jifty-DBI/trunk: lib/Jifty/DBI lib/Jifty/DBI/Filter

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Fri Jan 26 06:31:01 EST 2007


Author: audreyt
Date: Fri Jan 26 06:30:59 2007
New Revision: 2572

Modified:
   Jifty-DBI/trunk/lib/Jifty/DBI/Column.pm
   Jifty-DBI/trunk/lib/Jifty/DBI/Filter/Truncate.pm
   Jifty-DBI/trunk/lib/Jifty/DBI/Schema.pm
   Jifty-DBI/trunk/t/06filter_truncate.t

Log:
* Jifty::DBI - Thoroughly deprecate "length is 42" in favor of
  "max_length is 42". 

Modified: Jifty-DBI/trunk/lib/Jifty/DBI/Column.pm
==============================================================================
--- Jifty-DBI/trunk/lib/Jifty/DBI/Column.pm	(original)
+++ Jifty-DBI/trunk/lib/Jifty/DBI/Column.pm	Fri Jan 26 06:30:59 2007
@@ -12,7 +12,7 @@
     type
     default
     readable writable
-    length
+    max_length
     mandatory
     virtual
     distinct
@@ -76,4 +76,10 @@
 *read  = \&readable;
 *write = \&writable;
 
+sub length {
+    Carp::carp('$column->length is deprecated; use $column->max_length instead');
+    my $self = shift;
+    $self->max_length(@_);
+}
+
 1;

Modified: Jifty-DBI/trunk/lib/Jifty/DBI/Filter/Truncate.pm
==============================================================================
--- Jifty-DBI/trunk/lib/Jifty/DBI/Filter/Truncate.pm	(original)
+++ Jifty-DBI/trunk/lib/Jifty/DBI/Filter/Truncate.pm	Fri Jan 26 06:30:59 2007
@@ -15,8 +15,8 @@
     my $column = $self->column();
 
     my $truncate_to;
-    if ( $column->length && !$column->is_numeric ) {
-        $truncate_to = $column->length;
+    if ( $column->max_length && !$column->is_numeric ) {
+        $truncate_to = $column->max_length;
     } elsif ( $column->type && $column->type =~ /char\((\d+)\)/ ) {
         $truncate_to = $1;
     }

Modified: Jifty-DBI/trunk/lib/Jifty/DBI/Schema.pm
==============================================================================
--- Jifty-DBI/trunk/lib/Jifty/DBI/Schema.pm	(original)
+++ Jifty-DBI/trunk/lib/Jifty/DBI/Schema.pm	Fri Jan 26 06:30:59 2007
@@ -43,7 +43,7 @@
 use Carp qw/croak carp/;
 use Exporter::Lite;
 our @EXPORT
-    = qw(column type default literal validator autocompleted immutable unreadable length distinct mandatory not_null sort_order valid_values label hints render_as render since input_filters output_filters filters virtual is as by are on schema indexed valid order);
+    = qw(column type default literal validator autocompleted immutable unreadable max_length length distinct mandatory not_null sort_order valid_values label hints render_as render since input_filters output_filters filters virtual is as by are on schema indexed valid order);
 
 our $SCHEMA;
 our $SORT_ORDERS = {};
@@ -275,19 +275,32 @@
     _item( readable => 0, @_ );
 }
 
-=head2 length
+=head2 max_length
 
 Sets a maximum length to store in the database; values longer than
 this are truncated before being inserted into the database, using
 L<Jifty::DBI::Filter::Truncate>.  Note that this is in B<bytes>, not
-B<characters>.  Correct usage is C<length is 42>.
+B<characters>.  Correct usage is C<max_length is 42>.
+
+=cut
+
+sub max_length {
+    _list( max_length => @_ );
+}
+
+=head2 length
+
+DEPRECATED alias for C<max_length>.  Do not use; this will go away in the
+next version.
 
 =cut
 
 sub length {
-    _list( length => @_ );
+    Carp::carp("'length is ...' is deprecated; use 'length is ...' instead");
+    _list( max_length => @_ );
 }
 
+
 =head2 mandatory
 
 Mark as a required column.  May be used for generating user

Modified: Jifty-DBI/trunk/t/06filter_truncate.t
==============================================================================
--- Jifty-DBI/trunk/t/06filter_truncate.t	(original)
+++ Jifty-DBI/trunk/t/06filter_truncate.t	Fri Jan 26 06:30:59 2007
@@ -142,12 +142,12 @@
 
     column name =>
       type is 'varchar(10)',
-      length is 10,
+      max_length is 10,
       default is '';
 
     column disabled =>
       type is 'int(4)',
-      length is 4,
+      max_length is 4,
       default is 0;
     }
 }


More information about the Jifty-commit mailing list