Revision history for DBIx::Class
+ - Fix find() to use result_class set on object
+ - Fix result_class setter behaviour to not mistakenly stuff attrs.
+ - Don't try and ensure_class_loaded an object. This doesn't work.
- Add a warning to load_namespaces if a class in ResultSet/
is not a subclass of DBIx::Class::ResultSet
- ::Storage::DBI now correctly preserves a parent $dbh from
: $self->_add_alias($input_query, $alias);
}
- # Run the query
- my $rs = $self->search ($query, $attrs);
+ # Run the query, passing the result_class since it should propagate for find
+ my $rs = $self->search ($query, {result_class => $self->result_class, %$attrs});
if (keys %{$rs->_resolved_attrs->{collapse}}) {
my $row = $rs->next;
carp "Query returned more than one row" if $rs->next;
sub result_class {
my ($self, $result_class) = @_;
if ($result_class) {
- $self->ensure_class_loaded($result_class);
+ unless (ref $result_class) { # don't fire this for an object
+ $self->ensure_class_loaded($result_class);
+ }
$self->_result_class($result_class);
- $self->{attrs}{result_class} = $result_class if ref $self;
+ # THIS LINE WOULD BE A BUG - this accessor specifically exists to
+ # permit the user to set result class on one result set only; it only
+ # chains if provided to search()
+ #$self->{attrs}{result_class} = $result_class if ref $self;
}
$self->_result_class;
}
{
$schema ? (owner => $schema) : (),
table_name => $table || $source_name,
- triggering_event => 'INSERT',
+ triggering_event => { -like => '%INSERT%' },
status => 'ENABLED',
},
);
});
$dbh->do(qq{
CREATE OR REPLACE TRIGGER cd_insert_trg
- BEFORE INSERT ON cd
+ BEFORE INSERT OR UPDATE ON cd
FOR EACH ROW
BEGIN
IF :new.cdid IS NULL THEN
use Test::Warn;
use lib qw(t/lib);
use DBICTest;
+use DBIC::DebugObj;
{
package A::Comp;
DBICTest::Schema::CD->utf8_columns('title');
Class::C3->reinitialize();
-{
- package DBICTest::UTF8::Debugger;
-
- use base 'DBIx::Class::Storage::Statistics';
-
- __PACKAGE__->mk_group_accessors(simple => 'call_stack');
-
- sub query_start {
- my $self = shift;
- my $sql = shift;
-
- my @bind = map { substr $_, 1, -1 } (@_); # undo the effect of _fix_bind_params
-
- $self->call_stack ( [ @{$self->call_stack || [] }, [$sql, @bind] ] );
- $self->next::method ($sql, @_);
- }
-}
-
# as per http://search.cpan.org/dist/Test-Simple/lib/Test/More.pm#utf8
binmode (Test::More->builder->$_, ':utf8') for qw/output failure_output todo_output/;
cmp_ok ($bytestream_title, 'ne', $utf8_title, 'unicode/raw differ (sanity check)');
my $storage = $schema->storage;
-$storage->debugobj (DBICTest::UTF8::Debugger->new);
-$storage->debugobj->silence (1);
+my ($sql, @bind);
+my $debugobj = DBIC::DebugObj->new (\$sql, \@bind);
+my ($orig_debug, $orig_debugobj) = ($storage->debug, $storage->debugobj);
+$storage->debugobj ($debugobj);
$storage->debug (1);
my $cd = $schema->resultset('CD')->create( { artist => 1, title => $utf8_title, year => '2048' } );
-# bind values are always alphabetically ordered by column, thus [2]
+$storage->debugobj ($orig_debugobj);
+$storage->debug ($orig_debug);
+
+# bind values are always alphabetically ordered by column, thus [1]
+# the single quotes are an artefact of the debug-system
TODO: {
local $TODO = "This has been broken since rev 1191, Mar 2006";
- is ($storage->debugobj->call_stack->[-1][2], $bytestream_title, 'INSERT: raw bytes sent to the database');
+ is ($bind[1], "'$bytestream_title'", 'INSERT: raw bytes sent to the database');
}
# this should be using the cursor directly, no inflation/processing of any sort
$bytestream_title = $utf8_title = "something \x{219} else";
utf8::encode($bytestream_title);
+
+$storage->debugobj ($debugobj);
+$storage->debug (1);
+
$cd->update ({ title => $utf8_title });
-is ($storage->debugobj->call_stack->[-1][1], $bytestream_title, 'UPDATE: raw bytes sent to the database');
+
+$storage->debugobj ($orig_debugobj);
+$storage->debug ($orig_debug);
+
+is ($bind[0], "'$bytestream_title'", 'UPDATE: raw bytes sent to the database');
($raw_db_title) = $schema->resultset('CD')
->search ($cd->ident_condition)
->get_column('title')
# Under some versions of SQLite if the $rs is left hanging around it will lock
# So we create a scope here cos I'm lazy
{
- my $rs = $schema->resultset('CD')->search ({}, { order_by => 'cdid' });
+ my $rs = $schema->resultset('CD')->search ({}, {
+ order_by => 'cdid',
+ # use the hashref inflator class as result class
+ result_class => 'DBIx::Class::ResultClass::HashRefInflator',
+ });
# get the defined columns
my @dbic_cols = sort $rs->result_source->columns;
- # use the hashref inflator class as result class
- $rs->result_class('DBIx::Class::ResultClass::HashRefInflator');
-
# fetch first record
my $datahashref1 = $rs->first;
my $cd2 = $rs->search({ cdid => 1 })->single;
is_deeply ( $cd2, $datahashref1, 'first/search+single return the same thing');
+
+ $rs->result_class('DBIx::Class::Row');
+
+ is( $rs->result_class, 'DBIx::Class::Row', 'result_class set' );
+
+ is(
+ $rs->search->result_class, 'DBIx::Class::ResultClass::HashRefInflator',
+ 'result_class set using accessor does not propagate over search'
+ );
+
}
sub check_cols_of {
sub query_end { }
-sub txn_start { }
+sub txn_begin { }
sub txn_commit { }
push @fail_reasons, "Missing ./inc directory";
}
- if (not $mf_mtime) {
+ if(not $mf_mtime) {
push @fail_reasons, "Missing ./Makefile";
}
- elsif($mf_mtime < $mf_pl_mtime) {
- push @fail_reasons, "./Makefile.PL is newer than ./Makefile";
- }
-
- if ($mf_mtime < $optdeps_mtime) {
- push @fail_reasons, "./$optdeps is newer than ./Makefile";
+ else {
+ if($mf_mtime < $mf_pl_mtime) {
+ push @fail_reasons, "./Makefile.PL is newer than ./Makefile";
+ }
+ if($mf_mtime < $optdeps_mtime) {
+ push @fail_reasons, "./$optdeps is newer than ./Makefile";
+ }
}
if (@fail_reasons) {