[Rt-commit] r5726 - in DBIx-SearchBuilder/trunk: .
ruz at bestpractical.com
ruz at bestpractical.com
Tue Aug 8 20:38:55 EDT 2006
Author: ruz
Date: Tue Aug 8 20:38:55 2006
New Revision: 5726
Modified:
DBIx-SearchBuilder/trunk/ (props changed)
DBIx-SearchBuilder/trunk/SearchBuilder/Record.pm
Log:
r8662 at cubic-pc: cubic | 2006-08-09 04:47:44 +0400
::Record::Create and ::Record::__Set
* if field is of number type then convert '' to 0
* if field couldn't be NULL then use default value on create
* fix failing tests
Modified: DBIx-SearchBuilder/trunk/SearchBuilder/Record.pm
==============================================================================
--- DBIx-SearchBuilder/trunk/SearchBuilder/Record.pm (original)
+++ DBIx-SearchBuilder/trunk/SearchBuilder/Record.pm Tue Aug 8 20:38:55 2006
@@ -773,7 +773,17 @@
return ( $ret->return_value );
}
my $column = lc $args{'Column'};
- if ( !defined( $args{'Value'} ) ) {
+
+ if ( defined $args{'Value'} ) {
+ if ( $args{'Value'} eq '' &&
+ ( $self->_Accessible( $args{'Column'}, 'is_numeric' )
+ || ($self->_Accessible( $args{'Column'}, 'type' ) || '') =~ /INT/i ) )
+ {
+ $args{'Value'} = 0;
+ }
+ }
+
+ unless ( defined $args{'Value'} ) {
$ret->as_array( 0, "No value passed to _Set" );
$ret->as_error(
errno => 2,
@@ -1256,6 +1266,19 @@
'DBIx::SearchBuilder::Record' );
}
+ if ( defined $attribs{$key} ) {
+ if ( $attribs{$key} eq '' &&
+ ( $self->_Accessible( $key, 'is_numeric' )
+ || ($self->_Accessible( $key, 'type' ) || '') =~ /INT/i ) )
+ {
+ $attribs{$key} = 0;
+ }
+ }
+ else {
+ $attribs{$key} = $self->_Accessible( $key, 'default' )
+ if $self->_Accessible( $key, 'no_nulls' );
+ }
+
#Truncate things that are too long for their datatypes
$attribs{$key} = $self->TruncateValue( $key => $attribs{$key} );
More information about the Rt-commit
mailing list