id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY
,ref_type ENUM( 'H', 'A' ) NOT NULL DEFAULT 'H'
,refcount BIGINT UNSIGNED NOT NULL DEFAULT 1
+ ,classname LONGTEXT
);
CREATE TABLE datas (
,data_type ENUM( 'S', 'R' ) DEFAULT 'S'
,`key` LONGTEXT NOT NULL
,value LONGTEXT
- ,class LONGTEXT
,FOREIGN KEY (ref_id) REFERENCES refs (id)
ON DELETE CASCADE ON UPDATE CASCADE
,UNIQUE INDEX (ref_id, `key` (900) )
my $self = shift;
my ($obj) = @_;
- return;
+ my $sector = $self->load_sector( $obj->_base_offset, 'refs' )
+ or return;
+
+ return $sector->get_classname;
}
sub make_reference {
my $e = $self->engine;
unless ( $self->offset ) {
+ my $classname = Scalar::Util::blessed( delete $self->{data} );
$self->{offset} = $self->engine->storage->write_to(
refs => undef,
- ref_type => $self->type,
+ ref_type => $self->type,
+ classname => $classname,
);
}
else {
data_type => 'S',
key => $args->{key},
value => $args->{value}{data},
- class => $args->{value}{class},
);
$args->{value}->reload;
data_type => 'R',
key => $args->{key},
value => $args->{value}{offset},
- class => $args->{value}{class},
);
}
}
sub get_classname {
my $self = shift;
- return;
+ my ($rows) = $self->engine->storage->read_from(
+ 'refs', $self->offset,
+ qw( classname ),
+ );
+ return unless @$rows;
+ return $rows->[0]{classname};
}
sub data {
if ( $self->offset ) {
my ($rows) = $self->engine->storage->read_from(
datas => $self->offset,
- qw( id data_type key value class ),
+ qw( id data_type key value ),
);
- $self->{$_} = $rows->[0]{$_} for qw( data_type key value class );
+ $self->{$_} = $rows->[0]{$_} for qw( data_type key value );
}
return;