Permalink
Browse files

When type => 'boolean', default null_value to 0

  • Loading branch information...
Clinton Gormley
Clinton Gormley committed Jul 1, 2012
1 parent c9181a2 commit ab8b7d2458c08dddb05637847afe58a0f403a305

This file was deleted.

Oops, something went wrong.
@@ -312,8 +312,7 @@ sub attribute_mapping {
$mapping->{$key} = $val;
}
delete $mapping->{analyzer}
if $mapping->{index_analyzer} && $mapping->{search_analyzer};
$mapping = $map->_fixup_mapping($mapping);
my $multi = delete $mapping->{multi}
or return $mapping;
@@ -335,14 +334,27 @@ sub attribute_mapping {
unless $allowed->{$key} || $key eq 'type';
}
delete $defn->{analyzer}
if $defn->{index_analyzer} && $defn->{search_analyzer};
$new{fields}{$name} = $defn;
$new{fields}{$name} = $map->_fixup_mapping($defn);
}
return \%new;
}
#===================================
sub _fixup_mapping {
#===================================
my ( $map, $defn ) = @_;
delete $defn->{analyzer}
if $defn->{index_analyzer} && $defn->{search_analyzer};
# make 'undef' a false value for boolean fields
$defn->{null_value} = 0
if $defn->{type} eq 'boolean'
and not exists $defn->{null_value};
return $defn;
}
#===================================
sub deflators { shift->typemap->{deflator} }
sub inflators { shift->typemap->{inflator} }
@@ -21,7 +21,7 @@ has_type 'Undef',
#===================================
has_type 'Bool',
#===================================
map_via { type => 'boolean' };
map_via { type => 'boolean', null_value => 0 };
#===================================
has_type 'Str',
@@ -220,7 +220,12 @@ Mapping and in/deflation via L</Any>.
=head2 Bool
In/deflation via L</Any>. It is mapped as C<< { type => 'boolean' } >>.
In/deflation via L</Any>. It is mapped as:
{
type => 'boolean',
null_value => 0
}
=head2 Maybe
@@ -6,7 +6,7 @@ use warnings;
our $test_class = 'FieldTest::Boolean';
our @mapping = (
'basic' => { type => 'boolean' },
'basic' => { type => 'boolean', null_value => 0 },
'options' => {
boost => 2,
@@ -21,8 +21,8 @@ our @mapping = (
multi => {
type => "multi_field",
fields => {
multi_attr => { boost => 2, type => "boolean" },
one => { type => "string" },
multi_attr => { boost => 2, type => "boolean", null_value => 0 },
one => { type => "string" },
},
},

0 comments on commit ab8b7d2

Please sign in to comment.