'SQL::Abstract::Limit' => 0.101,
'DBD::SQLite' => 1.08,
'Class::C3' => 0.07,
- 'Tie::IxHash' => 0,
+ 'Tie::IxHash' => 0,
'Module::Find' => 0,
'Storable' => 0,
'Class::Data::Accessor' => 0.01,
return 1;
}
+sub search {
+ my $self = shift;
+ my $attrs = {};
+ if (@_ > 1 && ref $_[$#_] eq 'HASH') {
+ $attrs = { %{ pop(@_) } };
+ }
+ my $where = (@_ ? ((@_ == 1) ? ((ref $_[0] eq "HASH") ? { %{+shift} } : shift)
+ : {@_})
+ : undef());
+ if (ref $where eq 'HASH') {
+ foreach my $key (keys %$where) { # has_a deflation hack
+ $where->{$key} = ''.$where->{$key}
+ if eval { $where->{$key}->isa('DBIx::Class') };
+ }
+ }
+ $self->next::method($where, $attrs);
+}
+
1;
'TABLE' =>
sub {
my ($self, $class, $data) = @_;
- return $class->_table_name unless $data;
+ return $class->result_source_instance->name unless $data;
my ($f_class, $alias) = split(/=/, $data);
$f_class ||= $class;
$self->{_classes}{$alias} = $f_class;
- return $f_class->_table_name." ${alias}";
+ return $f_class->result_source_instance->name." ${alias}";
},
'ESSENTIAL' =>
sub {
my %want;
$want{$_} = 1 for map { keys %{$self->_column_groups->{$_}} } @groups;
if (my @want = grep { !exists $self->{'_column_data'}{$_} } keys %want) {
- my $cursor = $self->storage->select($self->_table_name, \@want,
+ my $cursor = $self->result_source->storage->select(
+ $self->result_source->name, \@want,
\$self->_ident_cond, { bind => [ $self->_ident_values ] });
#my $sth = $self->storage->select($self->_table_name, \@want,
# $self->ident_condition);
# trigger_body is a LONG
$dbh->{LongReadLen} = 64 * 1024 if ($dbh->{LongReadLen} < 64 * 1024);
my $sth = $dbh->prepare($sql);
- $sth->execute( uc($self->_table_name) );
+ $sth->execute( uc($self->result_source->name) );
while (my ($insert_trigger) = $sth->fetchrow_array) {
if ($insert_trigger =~ m!(\w+)\.nextval!i ) {
$self->{_autoinc_seq} = uc($1);
my $class = shift;
return $class->new_result(@_) if ref $class;
my ($source, $attrs) = @_;
- #use Data::Dumper; warn Dumper(@_);
+ #use Data::Dumper; warn Dumper($attrs);
$attrs = Storable::dclone($attrs || {}); # { %{ $attrs || {} } };
my %seen;
my $alias = ($attrs->{alias} ||= 'me');
--- /dev/null
+package DBIx::Class::ResultSourceInstance;
+
+use strict;
+use warnings;
+
+use base qw/DBIx::Class/;
+
+sub iterator_class { shift->result_source_instance->resultset_class(@_) }
+sub resultset_class { shift->result_source_instance->resultset_class(@_) }
+
+sub add_columns {
+ my ($class, @cols) = @_;
+ $class->result_source_instance->add_columns(@cols);
+ $class->_mk_column_accessors(@cols);
+}
+
+sub _select_columns {
+ return shift->result_source_instance->columns;
+}
+
+sub has_column {
+ my ($self, $column) = @_;
+ return $self->result_source_instance->has_column($column);
+}
+
+sub column_info {
+ my ($self, $column) = @_;
+ return $self->result_source_instance->column_info($column);
+}
+
+
+sub columns {
+ return shift->result_source_instance->columns(@_);
+}
+
+sub set_primary_key { shift->result_source_instance->set_primary_key(@_); }
+sub primary_columns { shift->result_source_instance->primary_columns(@_); }
+
+sub result_source { shift->result_source_instance(@_); }
+
+1;
return $self if $self->in_storage;
#use Data::Dumper; warn Dumper($self);
$self->result_source->storage->insert(
- $self->_table_name, { $self->get_columns });
+ $self->result_source->from, { $self->get_columns });
$self->in_storage(1);
$self->{_dirty_columns} = {};
return $self;
use strict;
use warnings;
-use base qw/DBIx::Class/;
+use base qw/DBIx::Class::ResultSourceInstance/;
use DBIx::Class::Table;
__PACKAGE__->mk_classdata('table_alias'); # FIXME: Doesn't actually do anything yet!
__PACKAGE__->mk_classdata('table_class' => 'DBIx::Class::Table');
-sub iterator_class { shift->result_source->resultset_class(@_) }
-sub resultset_class { shift->result_source->resultset_class(@_) }
-sub _table_name { shift->result_source->name }
-
=head1 NAME
DBIx::Class::TableInstance - provides a classdata table object and method proxies
=cut
-sub add_columns {
- my ($class, @cols) = @_;
- $class->result_source->add_columns(@cols);
- $class->_mk_column_accessors(@cols);
-}
-
-sub _select_columns {
- return shift->result_source->columns;
-}
-
=head2 table
__PACKAGE__->table('tbl_name');
sub table {
my ($class, $table) = @_;
- return $class->result_source->name unless $table;
+ return $class->result_source_instance->name unless $table;
unless (ref $table) {
$table = $class->table_class->new(
{
name => $table,
result_class => $class,
});
- if ($class->can('result_source')) {
- $table->{_columns} = { %{$class->result_source->{_columns}||{}} };
+ if ($class->can('result_source_instance')) {
+ $table->{_columns} = { %{$class->result_source_instance->{_columns}||{}} };
}
}
- $class->mk_classdata('result_source' => $table);
+ $class->mk_classdata('result_source_instance' => $table);
if ($class->can('schema_instance')) {
$class =~ m/([^:]+)$/;
$class->schema_instance->register_class($class, $class);
=cut
-sub has_column {
- my ($self, $column) = @_;
- return $self->result_source->has_column($column);
-}
-
=head2 column_info
my $info = $obj->column_info($col);
=cut
-sub column_info {
- my ($self, $column) = @_;
- return $self->result_source->column_info($column);
-}
-
=head2 columns
my @column_names = $obj->columns;
=cut
-sub columns {
- return shift->result_source->columns(@_);
-}
-
-sub set_primary_key { shift->result_source->set_primary_key(@_); }
-sub primary_columns { shift->result_source->primary_columns(@_); }
-
1;
=head1 AUTHORS