[Bast-commits] r3281 - in branches/DBIx-Class/bulk_create: .
lib/DBIx/Class lib/DBIx/Class/Storage lib/DBIx/Class/Storage/DBI t
matthewt at dev.catalyst.perl.org
matthewt at dev.catalyst.perl.org
Thu May 10 22:16:43 GMT 2007
Author: matthewt
Date: 2007-05-10 22:16:42 +0100 (Thu, 10 May 2007)
New Revision: 3281
Added:
branches/DBIx-Class/bulk_create/t/resultset_class.t
Modified:
branches/DBIx-Class/bulk_create/
branches/DBIx-Class/bulk_create/Changes
branches/DBIx-Class/bulk_create/Makefile.PL
branches/DBIx-Class/bulk_create/lib/DBIx/Class/ResultSource.pm
branches/DBIx-Class/bulk_create/lib/DBIx/Class/Storage.pm
branches/DBIx-Class/bulk_create/lib/DBIx/Class/Storage/DBI.pm
branches/DBIx-Class/bulk_create/lib/DBIx/Class/Storage/DBI/SQLite.pm
Log:
r50744 at cain (orig r3274): castaway | 2007-05-09 22:42:11 +0000
No nested transactions in SQLite.
r50745 at cain (orig r3275): claco | 2007-05-10 00:18:35 +0000
resultset_class/result_class now (again) auto loads the specified class; requires Class::Accessor::Grouped 0.05000+
r50749 at cain (orig r3279): blblack | 2007-05-10 21:11:04 +0000
do not try to silently handle disconnects when in a manual txn_begin/txn_end transaction
r50750 at cain (orig r3280): blblack | 2007-05-10 21:13:14 +0000
docs about side-effects in txn_do coderef
Property changes on: branches/DBIx-Class/bulk_create
___________________________________________________________________
Name: svk:merge
- 168d5346-440b-0410-b799-f706be625ff1:/DBIx-Class-current:2207
462d4d0c-b505-0410-bf8e-ce8f877b3390:/local/bast/DBIx-Class:3159
78d5d833-3a7e-474d-aed6-cfba645156b5:/local/DBIx-Class.current:29201
78d5d833-3a7e-474d-aed6-cfba645156b5:/local/DBIx-Class.oracle8:29250
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-C3:318
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-current:3266
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-joins:173
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-resultset:570
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/column_info_from_storage:2596
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/datetime:1716
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/find_compat:1855
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/find_unique_query_fixes:2142
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/inflate:1988
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/load_namespaces:2725
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/many_to_many:2025
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/param_bind:3015
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/re_refactor_bugfix:1944
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/reorganize_tests:1827
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/resultset-new-refactor:1766
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/resultset_2_electric_boogaloo:2175
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/resultset_cleanup:2102
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/source-handle:2975
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/sqlt_tests_refactor:2043
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/storage_exceptions:2617
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/versioning:2930
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/trunk/DBIx-Class:3225
+ 168d5346-440b-0410-b799-f706be625ff1:/DBIx-Class-current:2207
462d4d0c-b505-0410-bf8e-ce8f877b3390:/local/bast/DBIx-Class:3159
78d5d833-3a7e-474d-aed6-cfba645156b5:/local/DBIx-Class.current:29201
78d5d833-3a7e-474d-aed6-cfba645156b5:/local/DBIx-Class.oracle8:29250
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-C3:318
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-current:3280
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-joins:173
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-resultset:570
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/column_info_from_storage:2596
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/datetime:1716
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/find_compat:1855
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/find_unique_query_fixes:2142
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/inflate:1988
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/load_namespaces:2725
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/many_to_many:2025
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/param_bind:3015
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/re_refactor_bugfix:1944
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/reorganize_tests:1827
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/resultset-new-refactor:1766
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/resultset_2_electric_boogaloo:2175
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/resultset_cleanup:2102
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/source-handle:2975
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/sqlt_tests_refactor:2043
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/storage_exceptions:2617
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/versioning:2930
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/trunk/DBIx-Class:3225
Modified: branches/DBIx-Class/bulk_create/Changes
===================================================================
--- branches/DBIx-Class/bulk_create/Changes 2007-05-10 21:13:14 UTC (rev 3280)
+++ branches/DBIx-Class/bulk_create/Changes 2007-05-10 21:16:42 UTC (rev 3281)
@@ -8,6 +8,8 @@
- The SQL::T parser class now respects a relationship attribute of
is_foreign_key_constrain to allow explicit control over wether or
not a foreign constraint is needed
+ - resultset_class/result_class now (again) auto loads the specified
+ class; requires Class::Accessor::Grouped 0.05000+
0.07006 2007-04-17 23:18:00
- Lots of documentation updates
@@ -308,7 +310,8 @@
0.05002 2006-02-06 12:12:03
- Added recommends for Class::Inspector
- - Added skip_all to t/40resultsetmanager.t if no Class::Inspector available
+ - Added skip_all to t/40resultsetmanager.t if no Class::Inspector
+ available
0.05001 2006-02-05 15:28:10
- debug output now prints NULL for undef params
@@ -348,8 +351,10 @@
0.04999_04 2006-01-24 21:48:21
- more documentation improvements
- - add columns_info_for for vendor-specific column info (Zbigniew Lukasiak)
- - add SQL::Translator::Producer for DBIx::Class table classes (Jess Robinson)
+ - add columns_info_for for vendor-specific column info (Zbigniew
+ Lukasiak)
+ - add SQL::Translator::Producer for DBIx::Class table classes (Jess
+ Robinson)
- add unique constraint declaration (Daniel Westermann-Clark)
- add new update_or_create method (Daniel Westermann-Clark)
- rename ResultSetInstance class to ResultSetProxy, ResultSourceInstance
@@ -359,11 +364,13 @@
0.04999_03 2006-01-20 06:05:27
- imported Jess Robinson's SQL::Translator::Parser::DBIx::Class
- - lots of internals cleanup to eliminate result_source_instance requirement
+ - lots of internals cleanup to eliminate result_source_instance
+ requirement
- added register_column and register_relationship class APIs
- made Storage::DBI use prepare_cached safely (thanks to Tim Bunce)
- many documentation improvements (thanks guys!)
- - added ->connection, ->connect, ->register_source and ->clone schema methods
+ - added ->connection, ->connect, ->register_source and ->clone schema
+ methods
- Use croak instead of die for user errors.
0.04999_02 2006-01-14 07:17:35
@@ -436,3 +443,4 @@
0.01 2005-08-08 17:10:00
- initial release
+
Modified: branches/DBIx-Class/bulk_create/Makefile.PL
===================================================================
--- branches/DBIx-Class/bulk_create/Makefile.PL 2007-05-10 21:13:14 UTC (rev 3280)
+++ branches/DBIx-Class/bulk_create/Makefile.PL 2007-05-10 21:16:42 UTC (rev 3281)
@@ -15,7 +15,7 @@
requires 'DBI' => 1.40;
requires 'Module::Find' => 0;
requires 'Class::Inspector' => 0;
-requires 'Class::Accessor::Grouped' => 0.03;
+requires 'Class::Accessor::Grouped' => 0.05000;
requires 'JSON' => 1.00;
# Perl 5.8.0 doesn't have utf8::is_utf8()
Modified: branches/DBIx-Class/bulk_create/lib/DBIx/Class/ResultSource.pm
===================================================================
--- branches/DBIx-Class/bulk_create/lib/DBIx/Class/ResultSource.pm 2007-05-10 21:13:14 UTC (rev 3280)
+++ branches/DBIx-Class/bulk_create/lib/DBIx/Class/ResultSource.pm 2007-05-10 21:16:42 UTC (rev 3281)
@@ -14,7 +14,7 @@
_columns _primaries _unique_constraints name resultset_attributes
schema from _relationships column_info_from_storage source_info/);
-__PACKAGE__->mk_group_accessors('inherited' => qw/resultset_class
+__PACKAGE__->mk_group_accessors('component_class' => qw/resultset_class
result_class/);
__PACKAGE__->mk_group_ro_accessors('simple' => qw/source_name/);
Modified: branches/DBIx-Class/bulk_create/lib/DBIx/Class/Storage/DBI/SQLite.pm
===================================================================
--- branches/DBIx-Class/bulk_create/lib/DBIx/Class/Storage/DBI/SQLite.pm 2007-05-10 21:13:14 UTC (rev 3280)
+++ branches/DBIx-Class/bulk_create/lib/DBIx/Class/Storage/DBI/SQLite.pm 2007-05-10 21:16:42 UTC (rev 3281)
@@ -45,6 +45,15 @@
return $backupfile;
}
+sub txn_begin
+{
+ my $self = shift;
+ return if(!$self->{transaction_depth});
+
+ $self->next::method(@_);
+}
+
+
1;
=head1 NAME
Modified: branches/DBIx-Class/bulk_create/lib/DBIx/Class/Storage/DBI.pm
===================================================================
--- branches/DBIx-Class/bulk_create/lib/DBIx/Class/Storage/DBI.pm 2007-05-10 21:13:14 UTC (rev 3280)
+++ branches/DBIx-Class/bulk_create/lib/DBIx/Class/Storage/DBI.pm 2007-05-10 21:16:42 UTC (rev 3281)
@@ -506,7 +506,9 @@
ref $coderef eq 'CODE' or $self->throw_exception
('$coderef must be a CODE reference');
- return $coderef->($self, $self->_dbh, @_) if $self->{_in_dbh_do};
+ return $coderef->($self, $self->_dbh, @_) if $self->{_in_dbh_do}
+ || $self->{transaction_depth};
+
local $self->{_in_dbh_do} = 1;
my @result;
Modified: branches/DBIx-Class/bulk_create/lib/DBIx/Class/Storage.pm
===================================================================
--- branches/DBIx-Class/bulk_create/lib/DBIx/Class/Storage.pm 2007-05-10 21:13:14 UTC (rev 3280)
+++ branches/DBIx-Class/bulk_create/lib/DBIx/Class/Storage.pm 2007-05-10 21:16:42 UTC (rev 3281)
@@ -169,6 +169,15 @@
the outermost transaction will issue a L</txn_commit>, and txn_do() can be
called in void, scalar and list context and it will behave as expected.
+Please note that all of the code in your coderef, including non-DBIx::Class
+code, is part of a transaction. This transaction may fail out halfway, or
+it may get partially double-executed (in the case that our DB connection
+failed halfway through the transaction, in which case we reconnect and
+restart the txn). Therefore it is best that any side-effects in your coderef
+are idempotent (that is, can be re-executed multiple times and get the
+same result), and that you check up on your side-effects in the case of
+transaction failure.
+
=cut
sub txn_do {
Added: branches/DBIx-Class/bulk_create/t/resultset_class.t
===================================================================
--- branches/DBIx-Class/bulk_create/t/resultset_class.t (rev 0)
+++ branches/DBIx-Class/bulk_create/t/resultset_class.t 2007-05-10 21:16:42 UTC (rev 3281)
@@ -0,0 +1,22 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+use Test::More;
+use Class::Inspector ();
+
+unshift(@INC, './t/lib');
+use lib 't/lib';
+plan tests => 5;
+
+use DBICTest;
+
+is(DBICTest::Schema->source('Artist')->resultset_class, 'DBIx::Class::ResultSet', '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');
+is(DBICTest::Schema->source('Artist')->resultset_class, 'DBICNSTest::ResultSet::A', 'custom resultset class set');
+
+my $schema = DBICTest->init_schema;
+my $resultset = $schema->resultset('Artist')->search;
+isa_ok($resultset, 'DBICNSTest::ResultSet::A', 'resultset is custom class');
More information about the Bast-commits
mailing list