From: Peter Rabbitson Date: Sat, 16 May 2009 07:35:47 +0000 (+0000) Subject: Merge 'trunk' into 'joined_count' X-Git-Tag: v0.08103~64^2~7 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=5597834e4341123c5d6782ec8c0f66b4e7934e1d;hp=6100596b36d03566ade6a98ed4c375d317ff83f8;p=dbsrgits%2FDBIx-Class.git Merge 'trunk' into 'joined_count' r6264@Thesaurus (orig r6263): ribasushi | 2009-05-14 15:40:19 +0200 r6121@Thesaurus (orig r6120): caelum | 2009-05-04 17:13:22 +0200 Making new branch for storage tweaking r6122@Thesaurus (orig r6121): caelum | 2009-05-04 20:07:47 +0200 support hashrefs for connect_replicants r6123@Thesaurus (orig r6122): caelum | 2009-05-04 23:07:43 +0200 ::Replicated - test hashref for connect_replicants and croak on coderef, switch to MX::Types, make test less noisy r6143@Thesaurus (orig r6142): caelum | 2009-05-06 05:13:56 +0200 fix ::DBI::Replicated::all_storages r6144@Thesaurus (orig r6143): caelum | 2009-05-06 05:25:04 +0200 Replicated - fixup types and namespace::clean r6147@Thesaurus (orig r6146): caelum | 2009-05-06 15:29:39 +0200 ::DBI:Replicated - merge connect_info from master to replicants r6184@Thesaurus (orig r6183): caelum | 2009-05-08 18:08:29 +0200 support ::DBI::Replicated opts in connect_info r6190@Thesaurus (orig r6189): caelum | 2009-05-09 05:31:15 +0200 ::DBI::Replicated - add master_read_weight to ::Random balancer_type r6191@Thesaurus (orig r6190): caelum | 2009-05-09 12:50:25 +0200 ::DBI::Replicated - fix fallback to master, test for the warning, other cleanups r6193@Thesaurus (orig r6192): caelum | 2009-05-09 13:52:52 +0200 updated Changes r6194@Thesaurus (orig r6193): caelum | 2009-05-09 14:21:44 +0200 ::DBI::Replicated - don't build pool/balancer from connect_info unless necessary r6268@Thesaurus (orig r6267): caelum | 2009-05-15 04:04:12 +0200 minor replication changes - use a real hash merge, clarify master_read_weight, really done with this now. r6272@Thesaurus (orig r6271): abraxxa | 2009-05-15 13:45:54 +0200 added Static sub-classing DBIx::Class result classes section to the cookbook r6277@Thesaurus (orig r6276): ribasushi | 2009-05-16 00:46:00 +0200 Optimize some Ordered.pm code r6278@Thesaurus (orig r6277): ribasushi | 2009-05-16 08:02:18 +0200 Cleanup tests r6280@Thesaurus (orig r6279): ribasushi | 2009-05-16 09:30:05 +0200 Not sure what this part of the test is for, but it breaks custom resultsets, and the test passes without it. Removing as a possible remnant of an ancient civilization r6281@Thesaurus (orig r6280): ribasushi | 2009-05-16 09:33:24 +0200 Add default resultclass/resultsetclass to the entire test schema, as I am tired of typing extra shit for debugging purposes r6282@Thesaurus (orig r6281): ribasushi | 2009-05-16 09:34:21 +0200 Now we can do diag $rs->hri_dump, ain't that nice --- diff --git a/Changes b/Changes index 1c2127c..21c0431 100644 --- a/Changes +++ b/Changes @@ -16,6 +16,11 @@ Revision history for DBIx::Class circumvent DateTime parsing - Support inflation of timestamp datatype - Support BLOB and CLOB datatypes on Oracle + - Storage::DBI::Replicated::Balancer::Random: + added master_read_weight + - Storage::DBI::Replicated: storage opts from connect_info, + connect_info merging to replicants, hashref connect_info support, + improved trace output, other bug fixes/cleanups 0.08102 2009-04-30 08:29:00 (UTC) - Fixed two subtle bugs when using columns or select/as diff --git a/Makefile.PL b/Makefile.PL index 888e988..715ad7c 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -77,10 +77,11 @@ my %force_requires_if_author = ( , # t/93storage_replication.t - 'Moose', => 0.54, - 'Moose::Util::TypeConstraints' => 0.54, + 'Moose', => 0.77, 'MooseX::AttributeHelpers' => 0.12, - 'Class::MOP' => 0.63, + 'MooseX::Types', => 0.10, + 'namespace::clean' => 0.11, + 'Hash::Merge', => 0.11, # t/96_is_deteministic_value.t 'DateTime::Format::Strptime' => 0, diff --git a/lib/DBIx/Class/Manual/Cookbook.pod b/lib/DBIx/Class/Manual/Cookbook.pod index 5316c5a..574a8e1 100644 --- a/lib/DBIx/Class/Manual/Cookbook.pod +++ b/lib/DBIx/Class/Manual/Cookbook.pod @@ -733,6 +733,48 @@ Just use C instead, then check C: # do whatever else you wanted if it was a new row } +=head2 Static sub-classing DBIx::Class result classes + +AKA adding additional relationships/methods/etc. to a model for a +specific usage of the (shared) model. + +B + + package My::App::Schema; + + use base DBIx::Class::Schema; + + # load subclassed classes from My::App::Schema::Result/ResultSet + __PACKAGE__->load_namespaces; + + # load classes from shared model + load_classes({ + 'My::Shared::Model::Result' => [qw/ + Foo + Bar + /]}); + + 1; + +B + + package My::App::Schema::Result::Baz; + + use strict; + use warnings; + use base My::Shared::Model::Result::Baz; + + # WARNING: Make sure you call table() again in your subclass, + # otherwise DBIx::Class::ResultSourceProxy::Table will not be called + # and the class name is not correctly registered as a source + __PACKAGE__->table('baz'); + + sub additional_method { + return "I'm an additional method only needed by this app"; + } + + 1; + =head2 Dynamic Sub-classing DBIx::Class proxy classes AKA multi-class object inflation from one table @@ -760,7 +802,9 @@ B use base qw/DBIx::Class::Schema/; - __PACKAGE__->load_namespaces; + __PACKAGE__->load_namespaces; + + 1; B @@ -798,7 +842,9 @@ B print "I am a regular user.\n"; return ; } - + + 1; + package My::Schema::Result::User::Admin; @@ -816,7 +862,9 @@ B { print "I am doing admin stuff\n"; return ; - } + } + + 1; B test.pl diff --git a/lib/DBIx/Class/Ordered.pm b/lib/DBIx/Class/Ordered.pm index dc51856..b3fd102 100644 --- a/lib/DBIx/Class/Ordered.pm +++ b/lib/DBIx/Class/Ordered.pm @@ -272,6 +272,20 @@ sub last_sibling { return defined $lsib ? $lsib : 0; } +# an optimised method to get the last sibling position without inflating a row object +sub _last_sibling_pos { + my $self = shift; + my $position_column = $self->position_column; + + my $cursor = $self->next_siblings->search( + {}, + { rows => 1, order_by => { '-desc' => $position_column }, columns => $position_column }, + )->cursor; + + my ($pos) = $cursor->next; + return $pos; +} + =head2 move_previous $item->move_previous(); @@ -427,7 +441,7 @@ sub move_to_group { if ( not defined($to_position) or $to_position > $new_group_count) { $self->set_column( $position_column => $new_group_count - ? $self->_next_position_value ( $self->last_sibling->get_column ($position_column) ) # FIXME - no need to inflate last_sibling + ? $self->_next_position_value ( $self->_last_sibling_pos ) : $self->_initial_position_value ); } @@ -459,10 +473,10 @@ sub insert { my $position_column = $self->position_column; unless ($self->get_column($position_column)) { - my $lsib = $self->last_sibling; # FIXME - no need to inflate last_sibling + my $lsib_pos = $self->_last_sibling_pos; $self->set_column( - $position_column => ($lsib - ? $self->_next_position_value ( $lsib->get_column ($position_column) ) + $position_column => (defined $lsib_pos + ? $self->_next_position_value ( $lsib_pos ) : $self->_initial_position_value ) ); @@ -692,12 +706,22 @@ sub _shift_siblings { # position column is part of a unique constraint, and do a # one-by-one update if this is the case - if (grep { $_ eq $position_column } ( map { @$_ } (values %{{ $self->result_source->unique_constraints }} ) ) ) { + my $rsrc = $self->result_source; + + if (grep { $_ eq $position_column } ( map { @$_ } (values %{{ $rsrc->unique_constraints }} ) ) ) { + + my @pcols = $rsrc->primary_columns; + my $cursor = $shift_rs->search ({}, { order_by => { "-$ord", $position_column }, columns => \@pcols } )->cursor; + my $rs = $self->result_source->resultset; + + while (my @pks = $cursor->next ) { + + my $cond; + for my $i (0.. $#pcols) { + $cond->{$pcols[$i]} = $pks[$i]; + } - my $rs = $shift_rs->search ({}, { order_by => { "-$ord", $position_column } } ); - # FIXME - no need to inflate each row - while (my $r = $rs->next) { - $r->_ordered_internal_update ({ $position_column => \ "$position_column $op 1" } ); + $rs->search($cond)->update ({ $position_column => \ "$position_column $op 1" } ); } } else { diff --git a/lib/DBIx/Class/Storage/DBI/Replicated.pm b/lib/DBIx/Class/Storage/DBI/Replicated.pm index 89979f1..0dc50d7 100644 --- a/lib/DBIx/Class/Storage/DBI/Replicated.pm +++ b/lib/DBIx/Class/Storage/DBI/Replicated.pm @@ -7,10 +7,11 @@ BEGIN { ## use, so we explicitly test for these. my %replication_required = ( - Moose => '0.54', + Moose => '0.77', MooseX::AttributeHelpers => '0.12', - Moose::Util::TypeConstraints => '0.54', - Class::MOP => '0.63', + MooseX::Types => '0.10', + namespace::clean => '0.11', + Hash::Merge => '0.11' ); my @didnt_load; @@ -25,9 +26,17 @@ BEGIN { if @didnt_load; } +use Moose; use DBIx::Class::Storage::DBI; use DBIx::Class::Storage::DBI::Replicated::Pool; use DBIx::Class::Storage::DBI::Replicated::Balancer; +use DBIx::Class::Storage::DBI::Replicated::Types 'BalancerClassNamePart'; +use MooseX::Types::Moose qw/ClassName HashRef Object/; +use Scalar::Util 'reftype'; +use Carp::Clan qw/^DBIx::Class/; +use Hash::Merge 'merge'; + +use namespace::clean -except => 'meta'; =head1 NAME @@ -99,10 +108,11 @@ to force a query to run against Master when needed. Replicated Storage has additional requirements not currently part of L - Moose => 0.54 + Moose => 0.77 MooseX::AttributeHelpers => 0.12 - Moose::Util::TypeConstraints => 0.54 - Class::MOP => 0.63 + MooseX::Types => 0.10 + namespace::clean => 0.11 + Hash::Merge => 0.11 You will need to install these modules manually via CPAN or make them part of the Makefile for your distribution. @@ -132,9 +142,8 @@ to: L. =cut has 'pool_type' => ( - is=>'ro', - isa=>'ClassName', - required=>1, + is=>'rw', + isa=>ClassName, default=>'DBIx::Class::Storage::DBI::Replicated::Pool', handles=>{ 'create_pool' => 'new', @@ -149,10 +158,9 @@ See L for available arguments. =cut has 'pool_args' => ( - is=>'ro', - isa=>'HashRef', + is=>'rw', + isa=>HashRef, lazy=>1, - required=>1, default=>sub { {} }, ); @@ -164,23 +172,9 @@ choose how to spread the query load across each replicant in the pool. =cut -subtype 'DBIx::Class::Storage::DBI::Replicated::BalancerClassNamePart', - as 'ClassName'; - -coerce 'DBIx::Class::Storage::DBI::Replicated::BalancerClassNamePart', - from 'Str', - via { - my $type = $_; - if($type=~m/^::/) { - $type = 'DBIx::Class::Storage::DBI::Replicated::Balancer'.$type; - } - Class::MOP::load_class($type); - $type; - }; - has 'balancer_type' => ( - is=>'ro', - isa=>'DBIx::Class::Storage::DBI::Replicated::BalancerClassNamePart', + is=>'rw', + isa=>BalancerClassNamePart, coerce=>1, required=>1, default=> 'DBIx::Class::Storage::DBI::Replicated::Balancer::First', @@ -197,8 +191,8 @@ See L for available arguments. =cut has 'balancer_args' => ( - is=>'ro', - isa=>'HashRef', + is=>'rw', + isa=>HashRef, lazy=>1, required=>1, default=>sub { {} }, @@ -230,7 +224,7 @@ is a class that takes a pool () =cut has 'balancer' => ( - is=>'ro', + is=>'rw', isa=>'DBIx::Class::Storage::DBI::Replicated::Balancer', lazy_build=>1, handles=>[qw/auto_validate_every/], @@ -265,7 +259,7 @@ Defines an object that implements the read side of L. has 'read_handler' => ( is=>'rw', - isa=>'Object', + isa=>Object, lazy_build=>1, handles=>[qw/ select @@ -282,8 +276,7 @@ Defines an object that implements the write side of L. has 'write_handler' => ( is=>'ro', - isa=>'Object', - lazy_build=>1, + isa=>Object, lazy_build=>1, handles=>[qw/ on_connect_do @@ -317,6 +310,56 @@ has 'write_handler' => ( /], ); +has _master_connect_info_opts => + (is => 'rw', isa => HashRef, default => sub { {} }); + +=head2 around: connect_info + +Preserve master's C options (for merging with replicants.) +Also set any Replicated related options from connect_info, such as +C, C, C and C. + +=cut + +around connect_info => sub { + my ($next, $self, $info, @extra) = @_; + + my %opts; + for my $arg (@$info) { + next unless (reftype($arg)||'') eq 'HASH'; + %opts = %{ merge($arg, \%opts) }; + } + delete $opts{dsn}; + + if (@opts{qw/pool_type pool_args/}) { + $self->pool_type(delete $opts{pool_type}) + if $opts{pool_type}; + + $self->pool_args( + merge((delete $opts{pool_args} || {}), $self->pool_args) + ); + + $self->pool($self->_build_pool) + if $self->pool; + } + + if (@opts{qw/balancer_type balancer_args/}) { + $self->balancer_type(delete $opts{balancer_type}) + if $opts{balancer_type}; + + $self->balancer_args( + merge((delete $opts{balancer_args} || {}), $self->balancer_args) + ); + + $self->balancer($self->_build_balancer) + if $self->balancer; + } + + $self->_master_connect_info_opts(\%opts); + + $self->$next($info, @extra); +}; + =head1 METHODS This class defines the following methods. @@ -347,7 +390,9 @@ Lazy builder for the L attribute. sub _build_master { my $self = shift @_; - DBIx::Class::Storage::DBI->new($self->schema); + my $master = DBIx::Class::Storage::DBI->new($self->schema); + DBIx::Class::Storage::DBI::Replicated::WithDSN->meta->apply($master); + $master } =head2 _build_pool @@ -402,13 +447,49 @@ sub _build_read_handler { =head2 around: connect_replicants All calls to connect_replicants needs to have an existing $schema tacked onto -top of the args, since L needs it. +top of the args, since L needs it, and any C +options merged with the master, with replicant opts having higher priority. =cut -around 'connect_replicants' => sub { - my ($method, $self, @args) = @_; - $self->$method($self->schema, @args); +around connect_replicants => sub { + my ($next, $self, @args) = @_; + + for my $r (@args) { + $r = [ $r ] unless reftype $r eq 'ARRAY'; + + croak "coderef replicant connect_info not supported" + if ref $r->[0] && reftype $r->[0] eq 'CODE'; + +# any connect_info options? + my $i = 0; + $i++ while $i < @$r && (reftype($r->[$i])||'') ne 'HASH'; + +# make one if none + $r->[$i] = {} unless $r->[$i]; + +# merge if two hashes + my @hashes = @$r[$i .. $#{$r}]; + + croak "invalid connect_info options" + if (grep { reftype($_) eq 'HASH' } @hashes) != @hashes; + + croak "too many hashrefs in connect_info" + if @hashes > 2; + + my %opts = %{ merge(reverse @hashes) }; + +# delete them + splice @$r, $i+1, ($#{$r} - $i), (); + +# merge with master + %opts = %{ merge(\%opts, $self->_master_connect_info_opts) }; + +# update + $r->[$i] = \%opts; + } + + $self->$next($self->schema, @args); }; =head2 all_storages @@ -423,7 +504,7 @@ sub all_storages { my $self = shift @_; return grep {defined $_ && blessed $_} ( $self->master, - $self->replicants, + values %{ $self->replicants }, ); } @@ -693,6 +774,21 @@ sub disconnect { } } +=head2 cursor_class + +set cursor class on all storages, or return master's + +=cut + +sub cursor_class { + my ($self, $cursor_class) = @_; + + if ($cursor_class) { + $_->cursor_class($cursor_class) for $self->all_storages; + } + $self->master->cursor_class; +} + =head1 GOTCHAS Due to the fact that replicants can lag behind a master, you must take care to diff --git a/lib/DBIx/Class/Storage/DBI/Replicated/Balancer.pm b/lib/DBIx/Class/Storage/DBI/Replicated/Balancer.pm index 8af899c..798c0ef 100644 --- a/lib/DBIx/Class/Storage/DBI/Replicated/Balancer.pm +++ b/lib/DBIx/Class/Storage/DBI/Replicated/Balancer.pm @@ -2,6 +2,9 @@ package DBIx::Class::Storage::DBI::Replicated::Balancer; use Moose::Role; requires 'next_storage'; +use MooseX::Types::Moose qw/Int/; + +use namespace::clean -except => 'meta'; =head1 NAME @@ -31,7 +34,7 @@ validating every query. has 'auto_validate_every' => ( is=>'rw', - isa=>'Int', + isa=>Int, predicate=>'has_auto_validate_every', ); diff --git a/lib/DBIx/Class/Storage/DBI/Replicated/Balancer/First.pm b/lib/DBIx/Class/Storage/DBI/Replicated/Balancer/First.pm index e8fa630..b230346 100644 --- a/lib/DBIx/Class/Storage/DBI/Replicated/Balancer/First.pm +++ b/lib/DBIx/Class/Storage/DBI/Replicated/Balancer/First.pm @@ -2,6 +2,7 @@ package DBIx::Class::Storage::DBI::Replicated::Balancer::First; use Moose; with 'DBIx::Class::Storage::DBI::Replicated::Balancer'; +use namespace::clean -except => 'meta'; =head1 NAME @@ -50,4 +51,4 @@ You may distribute this code under the same terms as Perl itself. __PACKAGE__->meta->make_immutable; -1; \ No newline at end of file +1; diff --git a/lib/DBIx/Class/Storage/DBI/Replicated/Balancer/Random.pm b/lib/DBIx/Class/Storage/DBI/Replicated/Balancer/Random.pm index 6f786d3..f23db75 100644 --- a/lib/DBIx/Class/Storage/DBI/Replicated/Balancer/Random.pm +++ b/lib/DBIx/Class/Storage/DBI/Replicated/Balancer/Random.pm @@ -2,6 +2,8 @@ package DBIx::Class::Storage::DBI::Replicated::Balancer::Random; use Moose; with 'DBIx::Class::Storage::DBI::Replicated::Balancer'; +use DBIx::Class::Storage::DBI::Replicated::Types 'Weight'; +use namespace::clean -except => 'meta'; =head1 NAME @@ -26,6 +28,23 @@ you, patches welcome. This class defines the following attributes. +=head2 master_read_weight + +A number greater than 0 that specifies what weight to give the master when +choosing which backend to execute a read query on. A value of 0, which is the +default, does no reads from master, while a value of 1 gives it the same +priority as any single replicant. + +For example: if you have 2 replicants, and a L of C<0.5>, +the chance of reading from master will be C<20%>. + +You can set it to a value higher than 1, making master have higher weight than +any single replicant, if for example you have a very powerful master. + +=cut + +has master_read_weight => (is => 'rw', isa => Weight, default => sub { 0 }); + =head1 METHODS This class defines the following methods. @@ -40,11 +59,23 @@ be requested several times in a row. sub next_storage { my $self = shift @_; - my @active_replicants = $self->pool->active_replicants; - my $count_active_replicants = $#active_replicants +1; - my $random_replicant = int(rand($count_active_replicants)); - - return $active_replicants[$random_replicant]; + + my @replicants = $self->pool->active_replicants; + + if (not @replicants) { + # will fall back to master anyway + return; + } + + my $master = $self->master; + + my $rnd = $self->_random_number(@replicants + $self->master_read_weight); + + return $rnd >= @replicants ? $master : $replicants[int $rnd]; +} + +sub _random_number { + rand($_[1]) } =head1 AUTHOR @@ -59,4 +90,4 @@ You may distribute this code under the same terms as Perl itself. __PACKAGE__->meta->make_immutable; -1; \ No newline at end of file +1; diff --git a/lib/DBIx/Class/Storage/DBI/Replicated/Pool.pm b/lib/DBIx/Class/Storage/DBI/Replicated/Pool.pm index 76ca7f2..1b50a70 100644 --- a/lib/DBIx/Class/Storage/DBI/Replicated/Pool.pm +++ b/lib/DBIx/Class/Storage/DBI/Replicated/Pool.pm @@ -3,7 +3,12 @@ package DBIx::Class::Storage::DBI::Replicated::Pool; use Moose; use MooseX::AttributeHelpers; use DBIx::Class::Storage::DBI::Replicated::Replicant; -use List::Util qw(sum); +use List::Util 'sum'; +use Scalar::Util 'reftype'; +use Carp::Clan qw/^DBIx::Class/; +use MooseX::Types::Moose qw/Num Int ClassName HashRef/; + +use namespace::clean -except => 'meta'; =head1 NAME @@ -37,7 +42,7 @@ return a number of seconds that the replicating database is lagging. has 'maximum_lag' => ( is=>'rw', - isa=>'Num', + isa=>Num, required=>1, lazy=>1, default=>0, @@ -53,7 +58,7 @@ builtin. has 'last_validated' => ( is=>'rw', - isa=>'Int', + isa=>Int, reader=>'last_validated', writer=>'_last_validated', lazy=>1, @@ -70,7 +75,7 @@ just leave this alone. has 'replicant_type' => ( is=>'ro', - isa=>'ClassName', + isa=>ClassName, required=>1, default=>'DBIx::Class::Storage::DBI', handles=>{ @@ -120,7 +125,7 @@ removes the replicant under $key from the pool has 'replicants' => ( is=>'rw', metaclass => 'Collection::Hash', - isa=>'HashRef[DBIx::Class::Storage::DBI]', + isa=>HashRef['DBIx::Class::Storage::DBI'], default=>sub {{}}, provides => { 'set' => 'set_replicant', @@ -149,8 +154,18 @@ sub connect_replicants { my @newly_created = (); foreach my $connect_info (@_) { + $connect_info = [ $connect_info ] + if reftype $connect_info ne 'ARRAY'; + + croak "coderef replicant connect_info not supported" + if ref $connect_info->[0] && reftype $connect_info->[0] eq 'CODE'; + my $replicant = $self->connect_replicant($schema, $connect_info); - my ($key) = ($connect_info->[0]=~m/^dbi\:.+\:(.+)$/); + + my $key = $connect_info->[0]; + $key = $key->{dsn} if ref $key && reftype $key eq 'HASH'; + ($key) = ($key =~ m/^dbi\:.+\:(.+)$/); + $self->set_replicant( $key => $replicant); push @newly_created, $replicant; } @@ -280,13 +295,13 @@ sub validate_replicants { if($self->_safely_ensure_connected($replicant)) { my $is_replicating = $replicant->is_replicating; unless(defined $is_replicating) { - $replicant->debugobj->print("Storage Driver ".ref $self." Does not support the 'is_replicating' method. Assuming you are manually managing."); + $replicant->debugobj->print("Storage Driver ".ref($self)." Does not support the 'is_replicating' method. Assuming you are manually managing.\n"); next; } else { if($is_replicating) { my $lag_behind_master = $replicant->lag_behind_master; unless(defined $lag_behind_master) { - $replicant->debugobj->print("Storage Driver ".ref $self." Does not support the 'lag_behind_master' method. Assuming you are manually managing."); + $replicant->debugobj->print("Storage Driver ".ref($self)." Does not support the 'lag_behind_master' method. Assuming you are manually managing.\n"); next; } else { if($lag_behind_master <= $self->maximum_lag) { diff --git a/lib/DBIx/Class/Storage/DBI/Replicated/Replicant.pm b/lib/DBIx/Class/Storage/DBI/Replicated/Replicant.pm index e9612f3..9c9f1c2 100644 --- a/lib/DBIx/Class/Storage/DBI/Replicated/Replicant.pm +++ b/lib/DBIx/Class/Storage/DBI/Replicated/Replicant.pm @@ -2,6 +2,10 @@ package DBIx::Class::Storage::DBI::Replicated::Replicant; use Moose::Role; requires qw/_query_start/; +with 'DBIx::Class::Storage::DBI::Replicated::WithDSN'; +use MooseX::Types::Moose 'Bool'; + +use namespace::clean -except => 'meta'; =head1 NAME @@ -42,7 +46,7 @@ storage driver for more information. has 'active' => ( is=>'rw', - isa=>'Bool', + isa=>Bool, lazy=>1, required=>1, default=>1, @@ -52,18 +56,6 @@ has 'active' => ( This class defines the following methods. -=head2 around: _query_start - -advice iof the _query_start method to add more debuggin - -=cut - -around '_query_start' => sub { - my ($method, $self, $sql, @bind) = @_; - my $dsn = $self->_dbi_connect_info->[0]; - $self->$method("DSN: $dsn SQL: $sql", @bind); -}; - =head2 debugobj Override the debugobj method to redirect this method call back to the master. @@ -76,7 +68,8 @@ sub debugobj { =head1 ALSO SEE -L<http://en.wikipedia.org/wiki/Replicant> +L, +L =head1 AUTHOR @@ -88,4 +81,4 @@ You may distribute this code under the same terms as Perl itself. =cut -1; \ No newline at end of file +1; diff --git a/lib/DBIx/Class/Storage/DBI/Replicated/Types.pm b/lib/DBIx/Class/Storage/DBI/Replicated/Types.pm new file mode 100644 index 0000000..c366ea5 --- /dev/null +++ b/lib/DBIx/Class/Storage/DBI/Replicated/Types.pm @@ -0,0 +1,47 @@ +package # hide from PAUSE + DBIx::Class::Storage::DBI::Replicated::Types; + +=head1 NAME + +DBIx::Class::Storage::DBI::Replicated::Types - Types used internally by +L + +=cut + +use MooseX::Types + -declare => [qw/BalancerClassNamePart Weight/]; +use MooseX::Types::Moose qw/ClassName Str Num/; + +class_type 'DBIx::Class::Storage::DBI'; +class_type 'DBIx::Class::Schema'; + +subtype BalancerClassNamePart, + as ClassName; + +coerce BalancerClassNamePart, + from Str, + via { + my $type = $_; + if($type=~m/^::/) { + $type = 'DBIx::Class::Storage::DBI::Replicated::Balancer'.$type; + } + Class::MOP::load_class($type); + $type; + }; + +subtype Weight, + as Num, + where { $_ >= 0 }, + message { 'weight must be a decimal greater than 0' }; + +=head1 AUTHOR + + John Napiorkowski + +=head1 LICENSE + +You may distribute this code under the same terms as Perl itself. + +=cut + +1; diff --git a/lib/DBIx/Class/Storage/DBI/Replicated/WithDSN.pm b/lib/DBIx/Class/Storage/DBI/Replicated/WithDSN.pm new file mode 100644 index 0000000..69a3add --- /dev/null +++ b/lib/DBIx/Class/Storage/DBI/Replicated/WithDSN.pm @@ -0,0 +1,51 @@ +package DBIx::Class::Storage::DBI::Replicated::WithDSN; + +use Moose::Role; +requires qw/_query_start/; + +use namespace::clean -except => 'meta'; + +=head1 NAME + +DBIx::Class::Storage::DBI::Replicated::WithDSN - A DBI Storage Role with DSN +information in trace output + +=head1 SYNOPSIS + +This class is used internally by L. + +=head1 DESCRIPTION + +This role adds C info to storage debugging output. + +=head1 METHODS + +This class defines the following methods. + +=head2 around: _query_start + +Add C to debugging output. + +=cut + +around '_query_start' => sub { + my ($method, $self, $sql, @bind) = @_; + my $dsn = $self->_dbi_connect_info->[0]; + $self->$method("DSN: $dsn SQL: $sql", @bind); +}; + +=head1 ALSO SEE + +L + +=head1 AUTHOR + +John Napiorkowski + +=head1 LICENSE + +You may distribute this code under the same terms as Perl itself. + +=cut + +1; diff --git a/lib/DBIx/Class/Storage/Statistics.pm b/lib/DBIx/Class/Storage/Statistics.pm index b60c44e..22dcadc 100644 --- a/lib/DBIx/Class/Storage/Statistics.pm +++ b/lib/DBIx/Class/Storage/Statistics.pm @@ -5,7 +5,7 @@ use warnings; use base qw/Class::Accessor::Grouped/; use IO::File; -__PACKAGE__->mk_group_accessors(simple => qw/callback debugfh/); +__PACKAGE__->mk_group_accessors(simple => qw/callback debugfh silence/); =head1 NAME @@ -56,6 +56,8 @@ to display the message. sub print { my ($self, $msg) = @_; + return if $self->silence; + if(!defined($self->debugfh())) { my $fh; my $debug_env = $ENV{DBIX_CLASS_STORAGE_DBI_DEBUG} @@ -75,6 +77,10 @@ sub print { $self->debugfh->print($msg); } +=head2 silence + +Turn off all output if set to true. + =head2 txn_begin Called when a transaction begins. diff --git a/t/60core.t b/t/60core.t index c2f0c89..a568c6e 100644 --- a/t/60core.t +++ b/t/60core.t @@ -13,19 +13,6 @@ plan tests => 96; eval { require DateTime::Format::MySQL }; my $NO_DTFM = $@ ? 1 : 0; -# figure out if we've got a version of sqlite that is older than 3.2.6, in -# which case COUNT(DISTINCT()) doesn't work -my $is_broken_sqlite = 0; -my ($sqlite_major_ver,$sqlite_minor_ver,$sqlite_patch_ver) = - split /\./, $schema->storage->dbh->get_info(18); -if( $schema->storage->dbh->get_info(17) eq 'SQLite' && - ( ($sqlite_major_ver < 3) || - ($sqlite_major_ver == 3 && $sqlite_minor_ver < 2) || - ($sqlite_major_ver == 3 && $sqlite_minor_ver == 2 && $sqlite_patch_ver < 6) ) ) { - $is_broken_sqlite = 1; -} - - my @art = $schema->resultset("Artist")->search({ }, { order_by => 'name DESC'}); is(@art, 3, "Three artists returned"); @@ -245,10 +232,7 @@ is($or_rs->count, 4, 'Search with OR ok'); my $distinct_rs = $schema->resultset("CD")->search($search, { join => 'tags', distinct => 1 }); is($distinct_rs->all, 4, 'DISTINCT search with OR ok'); -SKIP: { - skip "SQLite < 3.2.6 doesn't understand COUNT(DISTINCT())", 2 - if $is_broken_sqlite; - +{ my $tcount = $schema->resultset('Track')->search( {}, { diff --git a/t/66relationship.t b/t/66relationship.t index a7f8771..65093c4 100644 --- a/t/66relationship.t +++ b/t/66relationship.t @@ -62,10 +62,10 @@ is( $big_flop_cd->title, 'Big Flop', 'create_related ok' ); } my( $rs_from_list ) = $artist->search_related_rs('cds'); -is( ref($rs_from_list), 'DBIx::Class::ResultSet', 'search_related_rs in list context returns rs' ); +isa_ok( $rs_from_list, 'DBIx::Class::ResultSet', 'search_related_rs in list context returns rs' ); ( $rs_from_list ) = $artist->cds_rs(); -is( ref($rs_from_list), 'DBIx::Class::ResultSet', 'relation_rs in list context returns rs' ); +isa_ok( $rs_from_list, 'DBIx::Class::ResultSet', 'relation_rs in list context returns rs' ); # count_related is( $artist->count_related('cds'), 4, 'count_related ok' ); diff --git a/t/76joins.t b/t/76joins.t index dad04b1..c6e795c 100644 --- a/t/76joins.t +++ b/t/76joins.t @@ -20,18 +20,6 @@ BEGIN { : ( tests => 33 ); } -# figure out if we've got a version of sqlite that is older than 3.2.6, in -# which case COUNT(DISTINCT()) doesn't work -my $is_broken_sqlite = 0; -my ($sqlite_major_ver,$sqlite_minor_ver,$sqlite_patch_ver) = - split /\./, $schema->storage->dbh->get_info(18); -if( $schema->storage->dbh->get_info(17) eq 'SQLite' && - ( ($sqlite_major_ver < 3) || - ($sqlite_major_ver == 3 && $sqlite_minor_ver < 2) || - ($sqlite_major_ver == 3 && $sqlite_minor_ver == 2 && $sqlite_patch_ver < 6) ) ) { - $is_broken_sqlite = 1; -} - # test the abstract join => SQL generator my $sa = new DBIx::Class::SQLAHacks; diff --git a/t/82cascade_copy.t b/t/82cascade_copy.t index 26b8425..5f8a542 100644 --- a/t/82cascade_copy.t +++ b/t/82cascade_copy.t @@ -11,14 +11,7 @@ plan tests => 4; my $artist = $schema->resultset('Artist')->find(1); my $artist_cds = $artist->search_related('cds'); -my $cover_band; - -{ - no warnings qw(redefine once); - local *DBICTest::Artist::result_source_instance = \&DBICTest::Schema::Artist::result_source_instance; - - $cover_band = $artist->copy; -} +my $cover_band = $artist->copy; my $cover_cds = $cover_band->search_related('cds'); cmp_ok($cover_band->id, '!=', $artist->id, 'ok got new column id...'); diff --git a/t/83cache.t b/t/83cache.t index 63de0d3..45f50c1 100644 --- a/t/83cache.t +++ b/t/83cache.t @@ -83,7 +83,7 @@ $artist = $rs->first; $rs->reset(); # make sure artist contains a related resultset for cds -is( ref $artist->{related_resultsets}->{cds}, 'DBIx::Class::ResultSet', 'artist has a related_resultset for cds' ); +isa_ok( $artist->{related_resultsets}{cds}, 'DBIx::Class::ResultSet', 'artist has a related_resultset for cds' ); # check if $artist->cds->get_cache is populated is( scalar @{$artist->cds->get_cache}, 3, 'cache for artist->cds contains correct number of records'); diff --git a/t/93storage_replication.t b/t/93storage_replication.t index b9ea61c..b85da4a 100644 --- a/t/93storage_replication.t +++ b/t/93storage_replication.t @@ -4,12 +4,15 @@ use lib qw(t/lib); use Test::More; use Test::Exception; use DBICTest; +use List::Util 'first'; +use Scalar::Util 'reftype'; +use IO::Handle; BEGIN { eval "use DBIx::Class::Storage::DBI::Replicated; use Test::Moose"; plan $@ ? ( skip_all => "Deps not installed: $@" ) - : ( tests => 79 ); + : ( tests => 90 ); } use_ok 'DBIx::Class::Storage::DBI::Replicated::Pool'; @@ -49,10 +52,10 @@ TESTSCHEMACLASSES: { ## Initialize the object sub new { - my $class = shift @_; + my ($class, $schema_method) = (shift, shift); my $self = $class->SUPER::new(@_); - $self->schema( $self->init_schema ); + $self->schema( $self->init_schema($schema_method) ); return $self; } @@ -62,30 +65,71 @@ TESTSCHEMACLASSES: { # current SQLT SQLite producer does not handle DROP TABLE IF EXISTS, trap warnings here local $SIG{__WARN__} = sub { warn @_ unless $_[0] =~ /no such table.+DROP TABLE/ }; - my $class = shift @_; - - my $schema = DBICTest->init_schema( - sqlite_use_file => 1, - storage_type=>{ - '::DBI::Replicated' => { - balancer_type=>'::Random', - balancer_args=>{ - auto_validate_every=>100, - }, - } - }, - deploy_args=>{ - add_drop_table => 1, - }, - ); + my ($class, $schema_method) = @_; + + my $method = "get_schema_$schema_method"; + my $schema = $class->$method; return $schema; } - + + sub get_schema_by_storage_type { + DBICTest->init_schema( + sqlite_use_file => 1, + storage_type=>{ + '::DBI::Replicated' => { + balancer_type=>'::Random', + balancer_args=>{ + auto_validate_every=>100, + master_read_weight => 1 + }, + } + }, + deploy_args=>{ + add_drop_table => 1, + }, + ); + } + + sub get_schema_by_connect_info { + DBICTest->init_schema( + sqlite_use_file => 1, + storage_type=> '::DBI::Replicated', + balancer_type=>'::Random', + balancer_args=> { + auto_validate_every=>100, + master_read_weight => 1 + }, + deploy_args=>{ + add_drop_table => 1, + }, + ); + } + sub generate_replicant_connect_info {} sub replicate {} sub cleanup {} + ## --------------------------------------------------------------------- ## + ## Add a connect_info option to test option merging. + ## --------------------------------------------------------------------- ## + { + package DBIx::Class::Storage::DBI::Replicated; + + use Moose; + + __PACKAGE__->meta->make_mutable; + + around connect_info => sub { + my ($next, $self, $info) = @_; + $info->[3]{master_option} = 1; + $self->$next($info); + }; + + __PACKAGE__->meta->make_immutable; + + no Moose; + } ## --------------------------------------------------------------------- ## ## Subclass for when you are using SQLite for testing, this provides a fake @@ -124,9 +168,20 @@ TESTSCHEMACLASSES: { "dbi:SQLite:${_}"; } @{$self->slave_paths}; - return map { [$_,'','',{AutoCommit=>1}] } @dsn; + my @connect_infos = map { [$_,'','',{AutoCommit=>1}] } @dsn; + + # try a hashref too + my $c = $connect_infos[0]; + $connect_infos[0] = { + dsn => $c->[0], + user => $c->[1], + password => $c->[2], + %{ $c->[3] } + }; + + @connect_infos } - + ## Do a 'good enough' replication by copying the master dbfile over each of ## the slave dbfiles. If the master is SQLite we do this, otherwise we ## just do a one second pause to let the slaves catch up. @@ -185,14 +240,22 @@ my $replicated_class = DBICTest->has_custom_dsn ? 'DBIx::Class::DBI::Replicated::TestReplication::Custom' : 'DBIx::Class::DBI::Replicated::TestReplication::SQLite'; -ok my $replicated = $replicated_class->new - => 'Created a replication object'; - -isa_ok $replicated->schema - => 'DBIx::Class::Schema'; - -isa_ok $replicated->schema->storage - => 'DBIx::Class::Storage::DBI::Replicated'; +my $replicated; + +for my $method (qw/by_connect_info by_storage_type/) { + ok $replicated = $replicated_class->new($method) + => "Created a replication object $method"; + + isa_ok $replicated->schema + => 'DBIx::Class::Schema'; + + isa_ok $replicated->schema->storage + => 'DBIx::Class::Storage::DBI::Replicated'; + + isa_ok $replicated->schema->storage->balancer + => 'DBIx::Class::Storage::DBI::Replicated::Balancer::Random' + => 'configured balancer_type'; +} ok $replicated->schema->storage->meta => 'has a meta object'; @@ -211,10 +274,38 @@ ok my @replicant_connects = $replicated->generate_replicant_connect_info ok my @replicated_storages = $replicated->schema->storage->connect_replicants(@replicant_connects) => 'Created some storages suitable for replicants'; - + +ok my @all_storages = $replicated->schema->storage->all_storages + => '->all_storages'; + +is scalar @all_storages, + 3 + => 'correct number of ->all_storages'; + +is ((grep $_->isa('DBIx::Class::Storage::DBI'), @all_storages), + 3 + => '->all_storages are correct type'); + +my @all_storage_opts = + grep { (reftype($_)||'') eq 'HASH' } + map @{ $_->_connect_info }, @all_storages; + +is ((grep $_->{master_option}, @all_storage_opts), + 3 + => 'connect_info was merged from master to replicants'); + +my @replicant_names = keys %{ $replicated->schema->storage->replicants }; + +## Silence warning about not supporting the is_replicating method if using the +## sqlite dbs. +$replicated->schema->storage->debugobj->silence(1) + if first { m{^t/} } @replicant_names; + isa_ok $replicated->schema->storage->balancer->current_replicant - => 'DBIx::Class::Storage::DBI'; - + => 'DBIx::Class::Storage::DBI'; + +$replicated->schema->storage->debugobj->silence(0); + ok $replicated->schema->storage->pool->has_replicants => 'does have replicants'; @@ -227,8 +318,6 @@ does_ok $replicated_storages[0] does_ok $replicated_storages[1] => 'DBIx::Class::Storage::DBI::Replicated::Replicant'; -my @replicant_names = keys %{$replicated->schema->storage->replicants}; - does_ok $replicated->schema->storage->replicants->{$replicant_names[0]} => 'DBIx::Class::Storage::DBI::Replicated::Replicant'; @@ -249,8 +338,16 @@ $replicated $replicated->replicate; $replicated->schema->storage->replicants->{$replicant_names[0]}->active(1); $replicated->schema->storage->replicants->{$replicant_names[1]}->active(1); + +## Silence warning about not supporting the is_replicating method if using the +## sqlite dbs. +$replicated->schema->storage->debugobj->silence(1) + if first { m{^t/} } @replicant_names; + $replicated->schema->storage->pool->validate_replicants; +$replicated->schema->storage->debugobj->silence(0); + ## Make sure we can read the data. ok my $artist1 = $replicated->schema->resultset('Artist')->find(4) @@ -262,6 +359,28 @@ isa_ok $artist1 is $artist1->name, 'Ozric Tentacles' => 'Found expected name for first result'; +## Check that master_read_weight is honored +{ + no warnings 'once'; + + # turn off redefined warning + local $SIG{__WARN__} = sub {}; + + local + *DBIx::Class::Storage::DBI::Replicated::Balancer::Random::_random_number = + sub { 999 }; + + $replicated->schema->storage->balancer->increment_storage; + + is $replicated->schema->storage->balancer->current_replicant, + $replicated->schema->storage->master + => 'master_read_weight is honored'; + + ## turn it off for the duration of the test + $replicated->schema->storage->balancer->master_read_weight(0); + $replicated->schema->storage->balancer->increment_storage; +} + ## Add some new rows that only the master will have This is because ## we overload any type of write operation so that is must hit the master ## database. @@ -350,14 +469,34 @@ ok $replicated->schema->resultset('Artist')->find(2) $replicated->schema->storage->replicants->{$replicant_names[0]}->active(0); $replicated->schema->storage->replicants->{$replicant_names[1]}->active(0); - -ok $replicated->schema->resultset('Artist')->find(2) - => 'Fallback to master'; + +{ + ## catch the fallback to master warning + open my $debugfh, '>', \my $fallback_warning; + my $oldfh = $replicated->schema->storage->debugfh; + $replicated->schema->storage->debugfh($debugfh); + + ok $replicated->schema->resultset('Artist')->find(2) + => 'Fallback to master'; + + like $fallback_warning, qr/falling back to master/ + => 'emits falling back to master warning'; + + $replicated->schema->storage->debugfh($oldfh); +} $replicated->schema->storage->replicants->{$replicant_names[0]}->active(1); $replicated->schema->storage->replicants->{$replicant_names[1]}->active(1); + +## Silence warning about not supporting the is_replicating method if using the +## sqlite dbs. +$replicated->schema->storage->debugobj->silence(1) + if first { m{^t/} } @replicant_names; + $replicated->schema->storage->pool->validate_replicants; +$replicated->schema->storage->debugobj->silence(0); + ok $replicated->schema->resultset('Artist')->find(2) => 'Returned to replicates'; @@ -577,3 +716,5 @@ ok $replicated->schema->resultset('Artist')->find(1) ## Delete the old database files $replicated->cleanup; + +# vim: sw=4 sts=4 : diff --git a/t/96multi_create.t b/t/96multi_create.t index 20b8c88..9cd754f 100644 --- a/t/96multi_create.t +++ b/t/96multi_create.t @@ -362,16 +362,16 @@ lives_ok ( sub { }); - ok( $cd_result && ref $cd_result eq 'DBICTest::CD', "Got Good CD Class"); + isa_ok( $cd_result, 'DBICTest::CD', "Got Good CD Class"); ok( $cd_result->title eq "TestOneCD1", "Got Expected Title"); my $tracks = $cd_result->tracks; - ok( ref $tracks eq "DBIx::Class::ResultSet", "Got Expected Tracks ResultSet"); + isa_ok( $tracks, 'DBIx::Class::ResultSet', 'Got Expected Tracks ResultSet'); foreach my $track ($tracks->all) { - ok( $track && ref $track eq 'DBICTest::Track', 'Got Expected Track Class'); + isa_ok( $track, 'DBICTest::Track', 'Got Expected Track Class'); } }, 'First create_related pass'); @@ -391,17 +391,17 @@ lives_ok ( sub { }); - ok( $cd_result && ref $cd_result eq 'DBICTest::CD', "Got Good CD Class"); + isa_ok( $cd_result, 'DBICTest::CD', "Got Good CD Class"); ok( $cd_result->title eq "TestOneCD2", "Got Expected Title"); ok( $cd_result->notes eq 'I can haz liner notes?', 'Liner notes'); my $tracks = $cd_result->tracks; - ok( ref $tracks eq "DBIx::Class::ResultSet", "Got Expected Tracks ResultSet"); + isa_ok( $tracks, 'DBIx::Class::ResultSet', "Got Expected Tracks ResultSet"); foreach my $track ($tracks->all) { - ok( $track && ref $track eq 'DBICTest::Track', 'Got Expected Track Class'); + isa_ok( $track, 'DBICTest::Track', 'Got Expected Track Class'); } }, 'second create_related with same arguments'); diff --git a/t/lib/DBICTest.pm b/t/lib/DBICTest.pm index d1d53c5..70501bf 100644 --- a/t/lib/DBICTest.pm +++ b/t/lib/DBICTest.pm @@ -75,7 +75,7 @@ sub _database { my $dbuser = $ENV{"DBICTEST_DBUSER"} || ''; my $dbpass = $ENV{"DBICTEST_DBPASS"} || ''; - my @connect_info = ($dsn, $dbuser, $dbpass, { AutoCommit => 1 }); + my @connect_info = ($dsn, $dbuser, $dbpass, { AutoCommit => 1, %args }); return @connect_info; } diff --git a/t/lib/DBICTest/BaseResult.pm b/t/lib/DBICTest/BaseResult.pm new file mode 100644 index 0000000..78de2a1 --- /dev/null +++ b/t/lib/DBICTest/BaseResult.pm @@ -0,0 +1,14 @@ +package #hide from pause + DBICTest::BaseResult; + +use strict; +use warnings; + +use base qw/DBIx::Class/; +use DBICTest::BaseResultSet; + +__PACKAGE__->load_components (qw/Core/); +__PACKAGE__->table ('bogus'); +__PACKAGE__->resultset_class ('DBICTest::BaseResultSet'); + +1; diff --git a/t/lib/DBICTest/BaseResultSet.pm b/t/lib/DBICTest/BaseResultSet.pm new file mode 100644 index 0000000..6d9df85 --- /dev/null +++ b/t/lib/DBICTest/BaseResultSet.pm @@ -0,0 +1,13 @@ +package #hide from pause + DBICTest::BaseResultSet; + +use strict; +use warnings; + +use base qw/DBIx::Class::ResultSet/; + +sub hri_dump { + return shift->search ({}, { result_class => 'DBIx::Class::ResultClass::HashRefInflator' }); +} + +1; diff --git a/t/lib/DBICTest/Schema/Artist.pm b/t/lib/DBICTest/Schema/Artist.pm index 959b4fc..b9794fe 100644 --- a/t/lib/DBICTest/Schema/Artist.pm +++ b/t/lib/DBICTest/Schema/Artist.pm @@ -1,7 +1,7 @@ package # hide from PAUSE DBICTest::Schema::Artist; -use base 'DBIx::Class::Core'; +use base qw/DBICTest::BaseResult/; __PACKAGE__->table('artist'); __PACKAGE__->source_info({ diff --git a/t/lib/DBICTest/Schema/ArtistUndirectedMap.pm b/t/lib/DBICTest/Schema/ArtistUndirectedMap.pm index c709572..1626787 100644 --- a/t/lib/DBICTest/Schema/ArtistUndirectedMap.pm +++ b/t/lib/DBICTest/Schema/ArtistUndirectedMap.pm @@ -1,7 +1,7 @@ package # hide from PAUSE DBICTest::Schema::ArtistUndirectedMap; -use base 'DBIx::Class::Core'; +use base qw/DBICTest::BaseResult/; __PACKAGE__->table('artist_undirected_map'); __PACKAGE__->add_columns( diff --git a/t/lib/DBICTest/Schema/Artwork.pm b/t/lib/DBICTest/Schema/Artwork.pm index 10e07ce..849096b 100644 --- a/t/lib/DBICTest/Schema/Artwork.pm +++ b/t/lib/DBICTest/Schema/Artwork.pm @@ -1,7 +1,7 @@ package # hide from PAUSE DBICTest::Schema::Artwork; -use base qw/DBIx::Class::Core/; +use base qw/DBICTest::BaseResult/; __PACKAGE__->table('cd_artwork'); __PACKAGE__->add_columns( diff --git a/t/lib/DBICTest/Schema/Artwork_to_Artist.pm b/t/lib/DBICTest/Schema/Artwork_to_Artist.pm index 0d832ca..0859080 100644 --- a/t/lib/DBICTest/Schema/Artwork_to_Artist.pm +++ b/t/lib/DBICTest/Schema/Artwork_to_Artist.pm @@ -1,7 +1,7 @@ package # hide from PAUSE DBICTest::Schema::Artwork_to_Artist; -use base qw/DBIx::Class::Core/; +use base qw/DBICTest::BaseResult/; __PACKAGE__->table('artwork_to_artist'); __PACKAGE__->add_columns( diff --git a/t/lib/DBICTest/Schema/BindType.pm b/t/lib/DBICTest/Schema/BindType.pm index e92a777..5670f2f 100644 --- a/t/lib/DBICTest/Schema/BindType.pm +++ b/t/lib/DBICTest/Schema/BindType.pm @@ -1,7 +1,7 @@ package # hide from PAUSE DBICTest::Schema::BindType; -use base 'DBIx::Class::Core'; +use base qw/DBICTest::BaseResult/; __PACKAGE__->table('bindtype_test'); diff --git a/t/lib/DBICTest/Schema/Bookmark.pm b/t/lib/DBICTest/Schema/Bookmark.pm index cac4841..bb32a14 100644 --- a/t/lib/DBICTest/Schema/Bookmark.pm +++ b/t/lib/DBICTest/Schema/Bookmark.pm @@ -1,7 +1,7 @@ package # hide from PAUSE DBICTest::Schema::Bookmark; - use base 'DBIx::Class::Core'; + use base qw/DBICTest::BaseResult/; use strict; diff --git a/t/lib/DBICTest/Schema/BooksInLibrary.pm b/t/lib/DBICTest/Schema/BooksInLibrary.pm index 6c2d6aa..1f5d7ea 100644 --- a/t/lib/DBICTest/Schema/BooksInLibrary.pm +++ b/t/lib/DBICTest/Schema/BooksInLibrary.pm @@ -1,7 +1,7 @@ package # hide from PAUSE DBICTest::Schema::BooksInLibrary; -use base qw/DBIx::Class::Core/; +use base qw/DBICTest::BaseResult/; __PACKAGE__->table('books'); __PACKAGE__->add_columns( diff --git a/t/lib/DBICTest/Schema/CD.pm b/t/lib/DBICTest/Schema/CD.pm index 513dd65..ec6ab24 100644 --- a/t/lib/DBICTest/Schema/CD.pm +++ b/t/lib/DBICTest/Schema/CD.pm @@ -1,7 +1,7 @@ package # hide from PAUSE DBICTest::Schema::CD; -use base 'DBIx::Class::Core'; +use base qw/DBICTest::BaseResult/; __PACKAGE__->table('cd'); __PACKAGE__->add_columns( diff --git a/t/lib/DBICTest/Schema/CD_to_Producer.pm b/t/lib/DBICTest/Schema/CD_to_Producer.pm index d8a9cc3..f0f14f0 100644 --- a/t/lib/DBICTest/Schema/CD_to_Producer.pm +++ b/t/lib/DBICTest/Schema/CD_to_Producer.pm @@ -1,7 +1,7 @@ package # hide from PAUSE DBICTest::Schema::CD_to_Producer; -use base 'DBIx::Class::Core'; +use base qw/DBICTest::BaseResult/; __PACKAGE__->table('cd_to_producer'); __PACKAGE__->add_columns( diff --git a/t/lib/DBICTest/Schema/Collection.pm b/t/lib/DBICTest/Schema/Collection.pm index 1c11dc6..e3df51f 100644 --- a/t/lib/DBICTest/Schema/Collection.pm +++ b/t/lib/DBICTest/Schema/Collection.pm @@ -1,7 +1,7 @@ package # hide from PAUSE DBICTest::Schema::Collection; -use base qw/DBIx::Class::Core/; +use base qw/DBICTest::BaseResult/; __PACKAGE__->table('collection'); __PACKAGE__->add_columns( diff --git a/t/lib/DBICTest/Schema/CollectionObject.pm b/t/lib/DBICTest/Schema/CollectionObject.pm index d05ae5d..df43c9c 100644 --- a/t/lib/DBICTest/Schema/CollectionObject.pm +++ b/t/lib/DBICTest/Schema/CollectionObject.pm @@ -1,7 +1,7 @@ package # hide from PAUSE DBICTest::Schema::CollectionObject; -use base qw/DBIx::Class::Core/; +use base qw/DBICTest::BaseResult/; __PACKAGE__->table('collection_object'); __PACKAGE__->add_columns( diff --git a/t/lib/DBICTest/Schema/Dummy.pm b/t/lib/DBICTest/Schema/Dummy.pm index 6bc51d6..2a8396d 100644 --- a/t/lib/DBICTest/Schema/Dummy.pm +++ b/t/lib/DBICTest/Schema/Dummy.pm @@ -1,7 +1,7 @@ package # hide from PAUSE DBICTest::Schema::Dummy; -use base 'DBIx::Class::Core'; +use base qw/DBICTest::BaseResult/; use strict; use warnings; diff --git a/t/lib/DBICTest/Schema/Employee.pm b/t/lib/DBICTest/Schema/Employee.pm index 258cab9..9bf015a 100644 --- a/t/lib/DBICTest/Schema/Employee.pm +++ b/t/lib/DBICTest/Schema/Employee.pm @@ -1,7 +1,7 @@ package # hide from PAUSE DBICTest::Schema::Employee; -use base 'DBIx::Class::Core'; +use base qw/DBICTest::BaseResult/; __PACKAGE__->load_components(qw( Ordered )); diff --git a/t/lib/DBICTest/Schema/Encoded.pm b/t/lib/DBICTest/Schema/Encoded.pm index 9d09f31..7fd77dc 100644 --- a/t/lib/DBICTest/Schema/Encoded.pm +++ b/t/lib/DBICTest/Schema/Encoded.pm @@ -1,7 +1,7 @@ package # hide from PAUSE DBICTest::Schema::Encoded; -use base 'DBIx::Class::Core'; +use base qw/DBICTest::BaseResult/; use strict; use warnings; diff --git a/t/lib/DBICTest/Schema/Event.pm b/t/lib/DBICTest/Schema/Event.pm index 0c02568..caecdc1 100644 --- a/t/lib/DBICTest/Schema/Event.pm +++ b/t/lib/DBICTest/Schema/Event.pm @@ -2,7 +2,7 @@ package DBICTest::Schema::Event; use strict; use warnings; -use base qw/DBIx::Class::Core/; +use base qw/DBICTest::BaseResult/; __PACKAGE__->load_components(qw/InflateColumn::DateTime/); diff --git a/t/lib/DBICTest/Schema/EventTZ.pm b/t/lib/DBICTest/Schema/EventTZ.pm index 1d5c06b..321b279 100644 --- a/t/lib/DBICTest/Schema/EventTZ.pm +++ b/t/lib/DBICTest/Schema/EventTZ.pm @@ -2,7 +2,7 @@ package DBICTest::Schema::EventTZ; use strict; use warnings; -use base qw/DBIx::Class::Core/; +use base qw/DBICTest::BaseResult/; __PACKAGE__->load_components(qw/InflateColumn::DateTime/); diff --git a/t/lib/DBICTest/Schema/EventTZDeprecated.pm b/t/lib/DBICTest/Schema/EventTZDeprecated.pm index 29695dd..8a9a11d 100644 --- a/t/lib/DBICTest/Schema/EventTZDeprecated.pm +++ b/t/lib/DBICTest/Schema/EventTZDeprecated.pm @@ -2,7 +2,7 @@ package DBICTest::Schema::EventTZDeprecated; use strict; use warnings; -use base qw/DBIx::Class::Core/; +use base qw/DBICTest::BaseResult/; __PACKAGE__->load_components(qw/InflateColumn::DateTime/); diff --git a/t/lib/DBICTest/Schema/FileColumn.pm b/t/lib/DBICTest/Schema/FileColumn.pm index cc425ee..82fcebd 100644 --- a/t/lib/DBICTest/Schema/FileColumn.pm +++ b/t/lib/DBICTest/Schema/FileColumn.pm @@ -3,7 +3,7 @@ DBICTest::Schema::FileColumn; use strict; use warnings; -use base qw/DBIx::Class::Core/; +use base qw/DBICTest::BaseResult/; use File::Temp qw/tempdir/; __PACKAGE__->load_components(qw/InflateColumn::File/); diff --git a/t/lib/DBICTest/Schema/ForceForeign.pm b/t/lib/DBICTest/Schema/ForceForeign.pm index 82829b8..8e2daeb 100644 --- a/t/lib/DBICTest/Schema/ForceForeign.pm +++ b/t/lib/DBICTest/Schema/ForceForeign.pm @@ -1,7 +1,7 @@ package # hide from PAUSE DBICTest::Schema::ForceForeign; -use base 'DBIx::Class::Core'; +use base qw/DBICTest::BaseResult/; __PACKAGE__->table('forceforeign'); __PACKAGE__->add_columns( diff --git a/t/lib/DBICTest/Schema/FourKeys.pm b/t/lib/DBICTest/Schema/FourKeys.pm index a1e23db..3fedb52 100644 --- a/t/lib/DBICTest/Schema/FourKeys.pm +++ b/t/lib/DBICTest/Schema/FourKeys.pm @@ -1,7 +1,7 @@ package # hide from PAUSE DBICTest::Schema::FourKeys; -use base 'DBIx::Class::Core'; +use base qw/DBICTest::BaseResult/; __PACKAGE__->table('fourkeys'); __PACKAGE__->add_columns( diff --git a/t/lib/DBICTest/Schema/FourKeys_to_TwoKeys.pm b/t/lib/DBICTest/Schema/FourKeys_to_TwoKeys.pm index 6e86313..5387136 100644 --- a/t/lib/DBICTest/Schema/FourKeys_to_TwoKeys.pm +++ b/t/lib/DBICTest/Schema/FourKeys_to_TwoKeys.pm @@ -1,7 +1,7 @@ package # hide from PAUSE DBICTest::Schema::FourKeys_to_TwoKeys; -use base 'DBIx::Class::Core'; +use base qw/DBICTest::BaseResult/; __PACKAGE__->table('fourkeys_to_twokeys'); __PACKAGE__->add_columns( diff --git a/t/lib/DBICTest/Schema/Genre.pm b/t/lib/DBICTest/Schema/Genre.pm index db2ca9c..3b3675a 100644 --- a/t/lib/DBICTest/Schema/Genre.pm +++ b/t/lib/DBICTest/Schema/Genre.pm @@ -2,7 +2,7 @@ package DBICTest::Schema::Genre; use strict; -use base 'DBIx::Class::Core'; +use base qw/DBICTest::BaseResult/; __PACKAGE__->table('genre'); __PACKAGE__->add_columns( diff --git a/t/lib/DBICTest/Schema/Image.pm b/t/lib/DBICTest/Schema/Image.pm index 8df5add..16f94a9 100644 --- a/t/lib/DBICTest/Schema/Image.pm +++ b/t/lib/DBICTest/Schema/Image.pm @@ -1,7 +1,7 @@ package # hide from PAUSE DBICTest::Schema::Image; -use base qw/DBIx::Class::Core/; +use base qw/DBICTest::BaseResult/; __PACKAGE__->table('images'); __PACKAGE__->add_columns( diff --git a/t/lib/DBICTest/Schema/LinerNotes.pm b/t/lib/DBICTest/Schema/LinerNotes.pm index 0c82588..5675f52 100644 --- a/t/lib/DBICTest/Schema/LinerNotes.pm +++ b/t/lib/DBICTest/Schema/LinerNotes.pm @@ -1,7 +1,7 @@ package # hide from PAUSE DBICTest::Schema::LinerNotes; -use base qw/DBIx::Class::Core/; +use base qw/DBICTest::BaseResult/; __PACKAGE__->table('liner_notes'); __PACKAGE__->add_columns( diff --git a/t/lib/DBICTest/Schema/Link.pm b/t/lib/DBICTest/Schema/Link.pm index 5343122..bf6d623 100644 --- a/t/lib/DBICTest/Schema/Link.pm +++ b/t/lib/DBICTest/Schema/Link.pm @@ -1,7 +1,7 @@ package # hide from PAUSE DBICTest::Schema::Link; -use base 'DBIx::Class::Core'; +use base qw/DBICTest::BaseResult/; use strict; use warnings; diff --git a/t/lib/DBICTest/Schema/LyricVersion.pm b/t/lib/DBICTest/Schema/LyricVersion.pm index d2f9769..2a409ab 100644 --- a/t/lib/DBICTest/Schema/LyricVersion.pm +++ b/t/lib/DBICTest/Schema/LyricVersion.pm @@ -1,7 +1,7 @@ package # hide from PAUSE DBICTest::Schema::LyricVersion; -use base qw/DBIx::Class::Core/; +use base qw/DBICTest::BaseResult/; __PACKAGE__->table('lyric_versions'); __PACKAGE__->add_columns( diff --git a/t/lib/DBICTest/Schema/Lyrics.pm b/t/lib/DBICTest/Schema/Lyrics.pm index 3e4024e..268a553 100644 --- a/t/lib/DBICTest/Schema/Lyrics.pm +++ b/t/lib/DBICTest/Schema/Lyrics.pm @@ -1,7 +1,7 @@ package # hide from PAUSE DBICTest::Schema::Lyrics; -use base qw/DBIx::Class::Core/; +use base qw/DBICTest::BaseResult/; __PACKAGE__->table('lyrics'); __PACKAGE__->add_columns( diff --git a/t/lib/DBICTest/Schema/NoPrimaryKey.pm b/t/lib/DBICTest/Schema/NoPrimaryKey.pm index 1edda61..cb79178 100644 --- a/t/lib/DBICTest/Schema/NoPrimaryKey.pm +++ b/t/lib/DBICTest/Schema/NoPrimaryKey.pm @@ -1,7 +1,7 @@ package # hide from PAUSE DBICTest::Schema::NoPrimaryKey; -use base 'DBIx::Class::Core'; +use base qw/DBICTest::BaseResult/; __PACKAGE__->table('noprimarykey'); __PACKAGE__->add_columns( diff --git a/t/lib/DBICTest/Schema/OneKey.pm b/t/lib/DBICTest/Schema/OneKey.pm index 63356ac..bd0e148 100644 --- a/t/lib/DBICTest/Schema/OneKey.pm +++ b/t/lib/DBICTest/Schema/OneKey.pm @@ -1,7 +1,7 @@ package # hide from PAUSE DBICTest::Schema::OneKey; -use base 'DBIx::Class::Core'; +use base qw/DBICTest::BaseResult/; __PACKAGE__->table('onekey'); __PACKAGE__->add_columns( diff --git a/t/lib/DBICTest/Schema/Owners.pm b/t/lib/DBICTest/Schema/Owners.pm index acaf5ed..38aa025 100644 --- a/t/lib/DBICTest/Schema/Owners.pm +++ b/t/lib/DBICTest/Schema/Owners.pm @@ -1,7 +1,7 @@ package # hide from PAUSE DBICTest::Schema::Owners; -use base qw/DBIx::Class::Core/; +use base qw/DBICTest::BaseResult/; __PACKAGE__->table('owners'); __PACKAGE__->add_columns( diff --git a/t/lib/DBICTest/Schema/Producer.pm b/t/lib/DBICTest/Schema/Producer.pm index 26ecddb..c2fa611 100644 --- a/t/lib/DBICTest/Schema/Producer.pm +++ b/t/lib/DBICTest/Schema/Producer.pm @@ -1,7 +1,7 @@ package # hide from PAUSE DBICTest::Schema::Producer; -use base 'DBIx::Class::Core'; +use base qw/DBICTest::BaseResult/; __PACKAGE__->table('producer'); __PACKAGE__->add_columns( diff --git a/t/lib/DBICTest/Schema/SelfRef.pm b/t/lib/DBICTest/Schema/SelfRef.pm index ec715c7..edcfe6c 100644 --- a/t/lib/DBICTest/Schema/SelfRef.pm +++ b/t/lib/DBICTest/Schema/SelfRef.pm @@ -1,7 +1,7 @@ package # hide from PAUSE DBICTest::Schema::SelfRef; -use base 'DBIx::Class::Core'; +use base qw/DBICTest::BaseResult/; __PACKAGE__->table('self_ref'); __PACKAGE__->add_columns( diff --git a/t/lib/DBICTest/Schema/SelfRefAlias.pm b/t/lib/DBICTest/Schema/SelfRefAlias.pm index e7ed491..2f7d105 100644 --- a/t/lib/DBICTest/Schema/SelfRefAlias.pm +++ b/t/lib/DBICTest/Schema/SelfRefAlias.pm @@ -1,7 +1,7 @@ package # hide from PAUSE DBICTest::Schema::SelfRefAlias; -use base 'DBIx::Class::Core'; +use base qw/DBICTest::BaseResult/; __PACKAGE__->table('self_ref_alias'); __PACKAGE__->add_columns( diff --git a/t/lib/DBICTest/Schema/SequenceTest.pm b/t/lib/DBICTest/Schema/SequenceTest.pm index bea3f4b..b0fa515 100644 --- a/t/lib/DBICTest/Schema/SequenceTest.pm +++ b/t/lib/DBICTest/Schema/SequenceTest.pm @@ -1,7 +1,7 @@ package # hide from PAUSE DBICTest::Schema::SequenceTest; -use base 'DBIx::Class::Core'; +use base qw/DBICTest::BaseResult/; __PACKAGE__->table('sequence_test'); __PACKAGE__->source_info({ diff --git a/t/lib/DBICTest/Schema/Serialized.pm b/t/lib/DBICTest/Schema/Serialized.pm index 687dcd1..92c210f 100644 --- a/t/lib/DBICTest/Schema/Serialized.pm +++ b/t/lib/DBICTest/Schema/Serialized.pm @@ -1,7 +1,7 @@ package # hide from PAUSE DBICTest::Schema::Serialized; -use base 'DBIx::Class::Core'; +use base qw/DBICTest::BaseResult/; __PACKAGE__->table('serialized'); __PACKAGE__->add_columns( diff --git a/t/lib/DBICTest/Schema/Tag.pm b/t/lib/DBICTest/Schema/Tag.pm index b75c2ef..796616e 100644 --- a/t/lib/DBICTest/Schema/Tag.pm +++ b/t/lib/DBICTest/Schema/Tag.pm @@ -1,7 +1,7 @@ package # hide from PAUSE DBICTest::Schema::Tag; -use base qw/DBIx::Class::Core/; +use base qw/DBICTest::BaseResult/; __PACKAGE__->table('tags'); __PACKAGE__->add_columns( diff --git a/t/lib/DBICTest/Schema/Track.pm b/t/lib/DBICTest/Schema/Track.pm index ee07f5e..4966800 100644 --- a/t/lib/DBICTest/Schema/Track.pm +++ b/t/lib/DBICTest/Schema/Track.pm @@ -1,7 +1,7 @@ package # hide from PAUSE DBICTest::Schema::Track; -use base 'DBIx::Class::Core'; +use base qw/DBICTest::BaseResult/; __PACKAGE__->load_components(qw/InflateColumn::DateTime Ordered/); __PACKAGE__->table('track'); diff --git a/t/lib/DBICTest/Schema/TreeLike.pm b/t/lib/DBICTest/Schema/TreeLike.pm index 365571d..a5413d1 100644 --- a/t/lib/DBICTest/Schema/TreeLike.pm +++ b/t/lib/DBICTest/Schema/TreeLike.pm @@ -1,7 +1,7 @@ package # hide from PAUSE DBICTest::Schema::TreeLike; -use base qw/DBIx::Class::Core/; +use base qw/DBICTest::BaseResult/; __PACKAGE__->table('treelike'); __PACKAGE__->add_columns( diff --git a/t/lib/DBICTest/Schema/TwoKeyTreeLike.pm b/t/lib/DBICTest/Schema/TwoKeyTreeLike.pm index 89d8e0a..1ee8409 100644 --- a/t/lib/DBICTest/Schema/TwoKeyTreeLike.pm +++ b/t/lib/DBICTest/Schema/TwoKeyTreeLike.pm @@ -1,7 +1,7 @@ package # hide from PAUSE DBICTest::Schema::TwoKeyTreeLike; -use base qw/DBIx::Class::Core/; +use base qw/DBICTest::BaseResult/; __PACKAGE__->table('twokeytreelike'); __PACKAGE__->add_columns( diff --git a/t/lib/DBICTest/Schema/TwoKeys.pm b/t/lib/DBICTest/Schema/TwoKeys.pm index 69af2e6..bfb6c42 100755 --- a/t/lib/DBICTest/Schema/TwoKeys.pm +++ b/t/lib/DBICTest/Schema/TwoKeys.pm @@ -1,7 +1,7 @@ package # hide from PAUSE DBICTest::Schema::TwoKeys; -use base 'DBIx::Class::Core'; +use base qw/DBICTest::BaseResult/; __PACKAGE__->table('twokeys'); __PACKAGE__->add_columns( diff --git a/t/lib/DBICTest/Schema/TypedObject.pm b/t/lib/DBICTest/Schema/TypedObject.pm index 6498add..50c5e44 100644 --- a/t/lib/DBICTest/Schema/TypedObject.pm +++ b/t/lib/DBICTest/Schema/TypedObject.pm @@ -1,7 +1,7 @@ package # hide from PAUSE DBICTest::Schema::TypedObject; -use base qw/DBIx::Class::Core/; +use base qw/DBICTest::BaseResult/; __PACKAGE__->table('typed_object'); __PACKAGE__->add_columns( diff --git a/t/lib/DBICTest/Schema/Year1999CDs.pm b/t/lib/DBICTest/Schema/Year1999CDs.pm index 580ed33..4aea122 100644 --- a/t/lib/DBICTest/Schema/Year1999CDs.pm +++ b/t/lib/DBICTest/Schema/Year1999CDs.pm @@ -2,7 +2,7 @@ package # hide from PAUSE DBICTest::Schema::Year1999CDs; ## Used in 104view.t -use base 'DBIx::Class::Core'; +use base qw/DBICTest::BaseResult/; use DBIx::Class::ResultSource::View; __PACKAGE__->table_class('DBIx::Class::ResultSource::View'); diff --git a/t/lib/DBICTest/Schema/Year2000CDs.pm b/t/lib/DBICTest/Schema/Year2000CDs.pm index 5293c69..ebc4395 100644 --- a/t/lib/DBICTest/Schema/Year2000CDs.pm +++ b/t/lib/DBICTest/Schema/Year2000CDs.pm @@ -2,7 +2,7 @@ package # hide from PAUSE DBICTest::Schema::Year2000CDs; ## Used in 104view.t -use base 'DBIx::Class::Core'; +use base qw/DBICTest::BaseResult/; use DBIx::Class::ResultSource::View; __PACKAGE__->table_class('DBIx::Class::ResultSource::View'); diff --git a/t/prefetch/attrs_untouched.t b/t/prefetch/attrs_untouched.t index 1742770..53894b8 100644 --- a/t/prefetch/attrs_untouched.t +++ b/t/prefetch/attrs_untouched.t @@ -19,18 +19,6 @@ BEGIN { : ( tests => 3 ); } -# figure out if we've got a version of sqlite that is older than 3.2.6, in -# which case COUNT(DISTINCT()) doesn't work -my $is_broken_sqlite = 0; -my ($sqlite_major_ver,$sqlite_minor_ver,$sqlite_patch_ver) = - split /\./, $schema->storage->dbh->get_info(18); -if( $schema->storage->dbh->get_info(17) eq 'SQLite' && - ( ($sqlite_major_ver < 3) || - ($sqlite_major_ver == 3 && $sqlite_minor_ver < 2) || - ($sqlite_major_ver == 3 && $sqlite_minor_ver == 2 && $sqlite_patch_ver < 6) ) ) { - $is_broken_sqlite = 1; -} - # bug in 0.07000 caused attr (join/prefetch) to be modifed by search # so we check the search & attr arrays are not modified my $search = { 'artist.name' => 'Caterwauler McCrae' }; diff --git a/t/prefetch/multiple_hasmany.t b/t/prefetch/multiple_hasmany.t index cee298a..7fc93812 100644 --- a/t/prefetch/multiple_hasmany.t +++ b/t/prefetch/multiple_hasmany.t @@ -20,18 +20,6 @@ BEGIN { : ( tests => 16 ); } -# figure out if we've got a version of sqlite that is older than 3.2.6, in -# which case COUNT(DISTINCT()) doesn't work -my $is_broken_sqlite = 0; -my ($sqlite_major_ver,$sqlite_minor_ver,$sqlite_patch_ver) = - split /\./, $schema->storage->dbh->get_info(18); -if( $schema->storage->dbh->get_info(17) eq 'SQLite' && - ( ($sqlite_major_ver < 3) || - ($sqlite_major_ver == 3 && $sqlite_minor_ver < 2) || - ($sqlite_major_ver == 3 && $sqlite_minor_ver == 2 && $sqlite_patch_ver < 6) ) ) { - $is_broken_sqlite = 1; -} - # once the following TODO is complete, remove the 2 warning tests immediately # after the TODO block # (the TODO block itself contains tests ensuring that the warns are removed) diff --git a/t/prefetch/pollute_already_joined.t b/t/prefetch/pollute_already_joined.t index 035aa5b..152ca56 100644 --- a/t/prefetch/pollute_already_joined.t +++ b/t/prefetch/pollute_already_joined.t @@ -20,18 +20,6 @@ BEGIN { : ( tests => 10 ); } -# figure out if we've got a version of sqlite that is older than 3.2.6, in -# which case COUNT(DISTINCT()) doesn't work -my $is_broken_sqlite = 0; -my ($sqlite_major_ver,$sqlite_minor_ver,$sqlite_patch_ver) = - split /\./, $schema->storage->dbh->get_info(18); -if( $schema->storage->dbh->get_info(17) eq 'SQLite' && - ( ($sqlite_major_ver < 3) || - ($sqlite_major_ver == 3 && $sqlite_minor_ver < 2) || - ($sqlite_major_ver == 3 && $sqlite_minor_ver == 2 && $sqlite_patch_ver < 6) ) ) { - $is_broken_sqlite = 1; -} - # A search() with prefetch seems to pollute an already joined resultset # in a way that offsets future joins (adapted from a test case by Debolaz) { diff --git a/t/prefetch/standard.t b/t/prefetch/standard.t index c25e010..56cf77d 100644 --- a/t/prefetch/standard.t +++ b/t/prefetch/standard.t @@ -20,18 +20,6 @@ BEGIN { : ( tests => 45 ); } -# figure out if we've got a version of sqlite that is older than 3.2.6, in -# which case COUNT(DISTINCT()) doesn't work -my $is_broken_sqlite = 0; -my ($sqlite_major_ver,$sqlite_minor_ver,$sqlite_patch_ver) = - split /\./, $schema->storage->dbh->get_info(18); -if( $schema->storage->dbh->get_info(17) eq 'SQLite' && - ( ($sqlite_major_ver < 3) || - ($sqlite_major_ver == 3 && $sqlite_minor_ver < 2) || - ($sqlite_major_ver == 3 && $sqlite_minor_ver == 2 && $sqlite_patch_ver < 6) ) ) { - $is_broken_sqlite = 1; -} - my $queries = 0; $schema->storage->debugcb(sub { $queries++; }); $schema->storage->debug(1); @@ -160,11 +148,7 @@ $rs = $schema->resultset("CD")->search( { group_by => [qw/ title me.cdid /] } ); -SKIP: { - skip "SQLite < 3.2.6 doesn't understand COUNT(DISTINCT())", 1 - if $is_broken_sqlite; - cmp_ok( $rs->count, '==', 5, "count() ok after group_by on main pk" ); -} +cmp_ok( $rs->count, '==', 5, "count() ok after group_by on main pk" ); cmp_ok( scalar $rs->all, '==', 5, "all() returns same count as count() after group_by on main pk" ); @@ -173,11 +157,7 @@ $rs = $schema->resultset("CD")->search( { join => [qw/ artist /], group_by => [qw/ artist.name /] } ); -SKIP: { - skip "SQLite < 3.2.6 doesn't understand COUNT(DISTINCT())", 1 - if $is_broken_sqlite; - cmp_ok( $rs->count, '==', 3, "count() ok after group_by on related column" ); -} +cmp_ok( $rs->count, '==', 3, "count() ok after group_by on related column" ); $rs = $schema->resultset("Artist")->search( {}, @@ -195,11 +175,7 @@ $rs = $schema->resultset("Artist")->search( 'cds_2.title' => 'Forkful of bees' }, { join => [ 'cds', 'cds' ] }); -SKIP: { - skip "SQLite < 3.2.6 doesn't understand COUNT(DISTINCT())", 1 - if $is_broken_sqlite; - cmp_ok($rs->count, '==', 1, "single artist returned from multi-join"); -} +cmp_ok($rs->count, '==', 1, "single artist returned from multi-join"); is($rs->next->name, 'Caterwauler McCrae', "Correct artist returned"); diff --git a/t/resultset_class.t b/t/resultset_class.t index 078c57b..f43a71e 100644 --- a/t/resultset_class.t +++ b/t/resultset_class.t @@ -11,7 +11,7 @@ plan tests => 5; use DBICTest; -is(DBICTest::Schema->source('Artist')->resultset_class, 'DBIx::Class::ResultSet', 'default resultset class'); +is(DBICTest::Schema->source('Artist')->resultset_class, 'DBICTest::BaseResultSet', 'default resultset class'); ok(!Class::Inspector->loaded('DBICNSTest::ResultSet::A'), 'custom resultset class not loaded'); DBICTest::Schema->source('Artist')->resultset_class('DBICNSTest::ResultSet::A'); ok(Class::Inspector->loaded('DBICNSTest::ResultSet::A'), 'custom resultset class loaded automatically');