unless ( $value_sector ) {
$value_sector = DBM::Deep::Sector::DBI::Scalar->new({
- engine => $self,
- data => undef,
+ engine => $self,
+ data => undef,
+ data_type => 'S',
});
$sector->write_data({
if ( $sector->{data_type} eq 'R' ) {
return $self->load(
- $engine, $sector->{offset}, 'refs',
+ $engine, $sector->{value}, 'refs',
);
}
my ($args) = @_;
if ( ( $args->{value}->type || 'S' ) eq 'S' ) {
- $self->engine->storage->write_to(
+ $args->{value}{offset} = $self->engine->storage->write_to(
datas => $args->{value}{offset},
ref_id => $self->offset,
data_type => 'S',
value => $args->{value}{data},
class => $args->{value}{class},
);
+
+ $args->{value}->reload;
}
else {
+ # Write the Scalar of the Reference
$self->engine->storage->write_to(
- datas => $args->{value}{offset},
+ datas => undef,
ref_id => $self->offset,
data_type => 'R',
key => $args->{key},
class => $args->{value}{class},
);
}
-
- $args->{value}->reload;
}
sub delete_key {
sub _init {
my $self = shift;
- my $engine = $self->engine;
- unless ( $self->offset ) {
-# my ($rows) = $self->engine->storage->write_to(
-# datas => undef,
-# ( map { $_ => $self->{$_} } qw( ref_id data_type key value class ) ),
-# );
- }
- else {
+ if ( $self->offset ) {
my ($rows) = $self->engine->storage->read_from(
datas => $self->offset,
- qw( data_type key value class ),
+ qw( id data_type key value class ),
);
$self->{$_} = $rows->[0]{$_} for qw( data_type key value class );
use Test::More;
use Test::Exception;
use t::common qw( new_dbm );
+use Scalar::Util qw( reftype );
use_ok( 'DBM::Deep' );
# Test autovivification
$db->{unknown}{bar} = 1;
ok( $db->{unknown}, 'Autovivified hash exists' );
+ is( reftype($db->{unknown}), 'HASH', "... and it's a HASH" );
cmp_ok( $db->{unknown}{bar}, '==', 1, 'And the value stored is there' );
# Test failures