[Bast-commits] r5318 - in
DBIx-Class/0.08/branches/sqla_1.50_compat: . lib/DBIx
lib/DBIx/Class lib/DBIx/Class/Manual
lib/DBIx/Class/ResultSourceProxy lib/DBIx/Class/Storage
lib/DBIx/Class/Storage/DBI t
norbi at dev.catalyst.perl.org
norbi at dev.catalyst.perl.org
Sun Jan 18 19:40:39 GMT 2009
Author: norbi
Date: 2009-01-18 19:40:39 +0000 (Sun, 18 Jan 2009)
New Revision: 5318
Modified:
DBIx-Class/0.08/branches/sqla_1.50_compat/
DBIx-Class/0.08/branches/sqla_1.50_compat/lib/DBIx/Class.pm
DBIx-Class/0.08/branches/sqla_1.50_compat/lib/DBIx/Class/DB.pm
DBIx-Class/0.08/branches/sqla_1.50_compat/lib/DBIx/Class/Manual/Glossary.pod
DBIx-Class/0.08/branches/sqla_1.50_compat/lib/DBIx/Class/Relationship.pm
DBIx-Class/0.08/branches/sqla_1.50_compat/lib/DBIx/Class/ResultSet.pm
DBIx-Class/0.08/branches/sqla_1.50_compat/lib/DBIx/Class/ResultSource.pm
DBIx-Class/0.08/branches/sqla_1.50_compat/lib/DBIx/Class/ResultSourceProxy/Table.pm
DBIx-Class/0.08/branches/sqla_1.50_compat/lib/DBIx/Class/Row.pm
DBIx-Class/0.08/branches/sqla_1.50_compat/lib/DBIx/Class/Schema.pm
DBIx-Class/0.08/branches/sqla_1.50_compat/lib/DBIx/Class/Storage/DBI.pm
DBIx-Class/0.08/branches/sqla_1.50_compat/lib/DBIx/Class/Storage/DBI/Pg.pm
DBIx-Class/0.08/branches/sqla_1.50_compat/t/39load_namespaces_1.t
DBIx-Class/0.08/branches/sqla_1.50_compat/t/76select.t
DBIx-Class/0.08/branches/sqla_1.50_compat/t/92storage_on_connect_do.t
Log:
r5390 at vger: mendel | 2009-01-12 11:30:01 +0100
r5351 at vger (orig r5266): norbi | 2008-12-21 01:39:44 +0100
r5350 at vger: mendel | 2008-12-21 01:39:37 +0100
* Added myself to the contributors list.
r5354 at vger (orig r5269): ribasushi | 2008-12-21 12:24:39 +0100
delete() POD patch from Michael Hendricks (slightly reworded)
r5365 at vger (orig r5278): nothingmuch | 2008-12-22 17:43:50 +0100
map blob to PG_BYTEA on DBD::Pg
r5366 at vger (orig r5279): matthewt | 2008-12-24 18:26:35 +0100
make clear that search_like is only really there for Class::DBI users
r5367 at vger (orig r5280): castaway | 2008-12-29 22:51:54 +0100
Added standard arguments/return value to all docced methods.
Upadted some method docs.
r5368 at vger (orig r5281): castaway | 2008-12-29 23:17:37 +0100
Re-ordered method docs to be in a more user-needs-it order.
Fixed some obj/table mentions in docs to be consistently $source.
r5369 at vger (orig r5282): castaway | 2008-12-30 11:58:19 +0100
Add definitions of relationship and relationship bridge, link to them from the rel docs
r5377 at vger (orig r5290): rjbs | 2009-01-08 21:49:29 +0100
failing test for callback on_connect_do getting storage obejct
r5378 at vger (orig r5291): rjbs | 2009-01-08 21:50:57 +0100
fix the just-added test; pass the Storage object to pure-code on_connect callbacks
r5379 at vger (orig r5292): rjbs | 2009-01-08 21:51:39 +0100
credit where credit is due; namely: ME!
r5381 at vger (orig r5294): wreis | 2009-01-08 23:45:35 +0100
failing test for load_namespace
r5382 at vger (orig r5295): wreis | 2009-01-08 23:57:47 +0100
->result_source_instance->source_name should return undef for any class
r5383 at vger (orig r5296): wreis | 2009-01-09 00:11:50 +0100
reverting changes for versioning tests
r5384 at vger (orig r5297): rjbs | 2009-01-09 02:55:53 +0100
by setting conn_?id first, we prevent $storage->dbh from recursing through on_connect_do actions
r5385 at vger (orig r5298): matthewt | 2009-01-09 04:28:44 +0100
fixup source registration bugs where schema-specific things were being set on class' result_source_instance objects
r5386 at vger (orig r5299): wreis | 2009-01-09 13:14:49 +0100
not necessary
r5389 at vger (orig r5300): norbi | 2009-01-12 11:18:47 +0100
r5388 at vger: mendel | 2009-01-12 11:18:22 +0100
* Implemented $rs->current_source_alias.
Property changes on: DBIx-Class/0.08/branches/sqla_1.50_compat
___________________________________________________________________
Name: svk:merge
- 168d5346-440b-0410-b799-f706be625ff1:/DBIx-Class-current:2207
462d4d0c-b505-0410-bf8e-ce8f877b3390:/local/bast/DBIx-Class:3159
4d5fae46-8e6a-4e08-abee-817e9fb894a2:/local/bast/DBIx-Class/0.08/branches/resultsetcolumn_custom_columns:5160
4d5fae46-8e6a-4e08-abee-817e9fb894a2:/local/bast/DBIx-Class/0.08/branches/sqla_1.50_compat:5348
4d5fae46-8e6a-4e08-abee-817e9fb894a2:/local/bast/DBIx-Class/0.08/trunk:5165
9c88509d-e914-0410-b01c-b9530614cbfe:/local/DBIx-Class:32260
9c88509d-e914-0410-b01c-b9530614cbfe:/local/DBIx-Class-CDBICompat:54993
9c88509d-e914-0410-b01c-b9530614cbfe:/vendor/DBIx-Class:31122
bd5ac9a7-f185-4d95-9186-dbb8b392a572:/local/os/bast/DBIx-Class/0.08/trunk:2798
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/belongs_to_null_col_fix:5244
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/cdbicompat_integration:4160
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/complex_join_rels:4589
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/file_column:3920
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/on_disconnect_do:3694
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/oracle_sequence:4173
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/parser_fk_index:4485
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/replication_dedux:4600
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/savepoints:4223
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/storage-ms-access:4142
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/versioned_enhancements:4125
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/versioning:4578
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/trunk:5260
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-C3:318
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-current:2222
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/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/many_to_many:2025
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/sqlt_tests_refactor:2043
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/trunk/DBIx-Class:3606
fe160bb6-dc1c-0410-9f2b-d64a711b54a5:/local/DBIC-trunk-0.08:10510
+ 168d5346-440b-0410-b799-f706be625ff1:/DBIx-Class-current:2207
462d4d0c-b505-0410-bf8e-ce8f877b3390:/local/bast/DBIx-Class:3159
4d5fae46-8e6a-4e08-abee-817e9fb894a2:/local/bast/DBIx-Class/0.08/branches/resultsetcolumn_custom_columns:5160
4d5fae46-8e6a-4e08-abee-817e9fb894a2:/local/bast/DBIx-Class/0.08/branches/sqla_1.50_compat:5390
4d5fae46-8e6a-4e08-abee-817e9fb894a2:/local/bast/DBIx-Class/0.08/trunk:5388
9c88509d-e914-0410-b01c-b9530614cbfe:/local/DBIx-Class:32260
9c88509d-e914-0410-b01c-b9530614cbfe:/local/DBIx-Class-CDBICompat:54993
9c88509d-e914-0410-b01c-b9530614cbfe:/vendor/DBIx-Class:31122
bd5ac9a7-f185-4d95-9186-dbb8b392a572:/local/os/bast/DBIx-Class/0.08/trunk:2798
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/belongs_to_null_col_fix:5244
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/cdbicompat_integration:4160
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/complex_join_rels:4589
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/file_column:3920
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/on_disconnect_do:3694
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/oracle_sequence:4173
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/parser_fk_index:4485
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/replication_dedux:4600
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/savepoints:4223
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/storage-ms-access:4142
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/versioned_enhancements:4125
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/versioning:4578
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/trunk:5300
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-C3:318
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-current:2222
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/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/many_to_many:2025
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/sqlt_tests_refactor:2043
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/trunk/DBIx-Class:3606
fe160bb6-dc1c-0410-9f2b-d64a711b54a5:/local/DBIC-trunk-0.08:10510
Modified: DBIx-Class/0.08/branches/sqla_1.50_compat/lib/DBIx/Class/DB.pm
===================================================================
--- DBIx-Class/0.08/branches/sqla_1.50_compat/lib/DBIx/Class/DB.pm 2009-01-18 00:44:43 UTC (rev 5317)
+++ DBIx-Class/0.08/branches/sqla_1.50_compat/lib/DBIx/Class/DB.pm 2009-01-18 19:40:39 UTC (rev 5318)
@@ -152,27 +152,47 @@
__PACKAGE__->mk_classdata('_result_source_instance' => []);
+# Yep. this is horrific. Basically what's happening here is that
+# (with good reason) DBIx::Class::Schema copies the result source for
+# registration. Because we have a retarded setup order forced on us we need
+# to actually make our ->result_source_instance -be- the source used, and we
+# need to get the source name and schema into ourselves. So this makes it
+# happen.
+
+sub _maybe_attach_source_to_schema {
+ my ($class, $source) = @_;
+ if (my $meth = $class->can('schema_instance')) {
+ my $schema = $class->$meth;
+ $schema->register_class($class, $class);
+ my $new_source = $schema->source($class);
+ %$source = %$new_source;
+ $schema->source_registrations->{$class} = $source;
+ }
+}
+
sub result_source_instance {
my $class = shift;
$class = ref $class || $class;
- return $class->_result_source_instance([$_[0], $class]) if @_;
+ if (@_) {
+ my $source = $_[0];
+ $class->_result_source_instance([$source, $class]);
+ $class->_maybe_attach_source_to_schema($source);
+ return $source;
+ }
my($source, $result_class) = @{$class->_result_source_instance};
return unless Scalar::Util::blessed($source);
if ($result_class ne $class) { # new class
# Give this new class it's own source and register it.
-
$source = $source->new({
%$source,
source_name => $class,
result_class => $class
} );
$class->_result_source_instance([$source, $class]);
- if (my $coderef = $class->can('schema_instance')) {
- $coderef->($class)->register_class($class, $class);
- }
+ $class->_maybe_attach_source_to_schema($source);
}
return $source;
}
Modified: DBIx-Class/0.08/branches/sqla_1.50_compat/lib/DBIx/Class/Manual/Glossary.pod
===================================================================
--- DBIx-Class/0.08/branches/sqla_1.50_compat/lib/DBIx/Class/Manual/Glossary.pod 2009-01-18 00:44:43 UTC (rev 5317)
+++ DBIx-Class/0.08/branches/sqla_1.50_compat/lib/DBIx/Class/Manual/Glossary.pod 2009-01-18 19:40:39 UTC (rev 5318)
@@ -36,6 +36,18 @@
way it's a method of mapping the contents of database tables (rows),
to objects in programming-language-space. DBIx::Class is an ORM.
+=head2 Relationship
+
+In DBIx::Class a relationship defines the connection between exactly
+two tables. The relationship condition lists the columns in each table
+that contain the same values. It is used to output an SQL JOIN
+condition between the tables.
+
+=head2 Relationship bridge
+
+A relationship bridge, such as C<many_to_many> defines an accessor to
+retrieve row contents across multiple relationships.
+
=head2 ResultSet
This is an object representing a set of data. It can either be an
Modified: DBIx-Class/0.08/branches/sqla_1.50_compat/lib/DBIx/Class/Relationship.pm
===================================================================
--- DBIx-Class/0.08/branches/sqla_1.50_compat/lib/DBIx/Class/Relationship.pm 2009-01-18 00:44:43 UTC (rev 5317)
+++ DBIx-Class/0.08/branches/sqla_1.50_compat/lib/DBIx/Class/Relationship.pm 2009-01-18 19:40:39 UTC (rev 5318)
@@ -39,6 +39,9 @@
=head1 DESCRIPTION
+The word I<Relationship> has a specific meaning in DBIx::Class, see
+the definition in the L<Glossary|DBIx::Class::Manual::Glossary/Relationship>.
+
This class provides methods to set up relationships between the tables
in your database model. Relationships are the most useful and powerful
technique that L<DBIx::Class> provides. To create efficient database queries,
@@ -102,20 +105,20 @@
All helper methods are called similar to the following template:
- __PACKAGE__->$method_name('relname', 'Foreign::Class', $cond, $attrs);
+ __PACKAGE__->$method_name('relname', 'Foreign::Class', \%cond | \@cond, \%attrs);
Both C<$cond> and C<$attrs> are optional. Pass C<undef> for C<$cond> if
-you want to use the default value for it, but still want to set C<$attrs>.
+you want to use the default value for it, but still want to set C<\%attrs>.
See L<DBIx::Class::Relationship::Base> for documentation on the
-attrubutes that are allowed in the C<$attrs> argument.
+attrubutes that are allowed in the C<\%attrs> argument.
=head2 belongs_to
=over 4
-=item Arguments: $accessor_name, $related_class, $our_fk_column|\%cond|\@cond?, \%attr?
+=item Arguments: $accessor_name, $related_class, $our_fk_column|\%cond|\@cond?, \%attrs?
=back
@@ -225,7 +228,7 @@
=over 4
-=item Arguments: $accessor_name, $related_class, $their_fk_column|\%cond|\@cond?, \%attr?
+=item Arguments: $accessor_name, $related_class, $their_fk_column|\%cond|\@cond?, \%attrs?
=back
@@ -358,7 +361,7 @@
=over 4
-=item Arguments: $accessor_name, $related_class, $their_fk_column|\%cond|\@cond?, \%attr?
+=item Arguments: $accessor_name, $related_class, $their_fk_column|\%cond|\@cond?, \%attrs?
=back
@@ -442,7 +445,7 @@
=over 4
-=item Arguments: $accessor_name, $related_class, $their_fk_column|\%cond|\@cond?, \%attr?
+=item Arguments: $accessor_name, $related_class, $their_fk_column|\%cond|\@cond?, \%attrs?
=back
@@ -529,10 +532,14 @@
=over 4
-=item Arguments: $accessor_name, $link_rel_name, $foreign_rel_name, \%attr?
+=item Arguments: $accessor_name, $link_rel_name, $foreign_rel_name, \%attrs?
=back
+C<many_to_many> is a I<Relationship bridge> which has a specific
+meaning in DBIx::Class, see the definition in the
+L<Glossary|DBIx::Class::Manual::Glossary/Relationship bridge>.
+
C<many_to_many> is not strictly a relationship in its own right. Instead, it is
a bridge between two resultsets which provide the same kind of convenience
accessors as true relationships provide. Although the accessor will return a
Modified: DBIx-Class/0.08/branches/sqla_1.50_compat/lib/DBIx/Class/ResultSet.pm
===================================================================
--- DBIx-Class/0.08/branches/sqla_1.50_compat/lib/DBIx/Class/ResultSet.pm 2009-01-18 00:44:43 UTC (rev 5317)
+++ DBIx-Class/0.08/branches/sqla_1.50_compat/lib/DBIx/Class/ResultSet.pm 2009-01-18 19:40:39 UTC (rev 5318)
@@ -737,8 +737,8 @@
$cd_rs = $rs->search_like({ title => '%blue%'});
Performs a search, but uses C<LIKE> instead of C<=> as the condition. Note
-that this is simply a convenience method. You most likely want to use
-L</search> with specific operators.
+that this is simply a convenience method retained for ex Class::DBI users.
+You most likely want to use L</search> with specific operators.
For more information, see L<DBIx::Class::Manual::Cookbook>.
@@ -2094,6 +2094,50 @@
};
}
+=head2 current_source_alias
+
+=over 4
+
+=item Arguments: none
+
+=item Return Value: $source_alias
+
+=back
+
+Returns the current alias of the result source that corrensponds to the result
+set (this alias will eventually be used as the SQL table alias in the SQL
+query). Usually it is C<me>.
+
+Currently the source alias that refers to the result set returned by a
+L</search>/L</find> family method depends on how you got to the resultset: it's
+C<me> by default, but eg. L</search_related> aliases it to the related result
+source name (and keeps C<me> referring to the original result set). The long
+term goal is to make L<DBIx::Class> always alias the current resultset as C<me>
+(and make this method unnecessary).
+
+Thus it's currently necessary to use this method in predefined queries (see
+L<DBIx::Class::Manual::Cookbook/Predefined searches>) when referring to the
+source alias of the current result set:
+
+ # in a result set class
+ sub modified_by {
+ my ($self, $user) = @_;
+
+ my $me = $self->current_source_alias;
+
+ return $self->search(
+ "$me.modified" => $user->id,
+ );
+ }
+
+=cut
+
+sub current_source_alias {
+ my ($self) = @_;
+
+ return ($self->{attrs} || {})->{alias} || 'me';
+}
+
sub _resolve_from {
my ($self, $extra_join) = @_;
my $source = $self->result_source;
Modified: DBIx-Class/0.08/branches/sqla_1.50_compat/lib/DBIx/Class/ResultSource.pm
===================================================================
--- DBIx-Class/0.08/branches/sqla_1.50_compat/lib/DBIx/Class/ResultSource.pm 2009-01-18 00:44:43 UTC (rev 5317)
+++ DBIx-Class/0.08/branches/sqla_1.50_compat/lib/DBIx/Class/ResultSource.pm 2009-01-18 19:40:39 UTC (rev 5318)
@@ -33,14 +33,6 @@
=pod
-=head2 new
-
- $class->new();
-
- $class->new({attribute_name => value});
-
-Creates a new ResultSource object. Not normally called directly by end users.
-
=cut
sub new {
@@ -60,23 +52,20 @@
=pod
-=head2 source_info
+=head2 add_columns
-Stores a hashref of per-source metadata. No specific key names
-have yet been standardized, the examples below are purely hypothetical
-and don't actually accomplish anything on their own:
+=over
- __PACKAGE__->source_info({
- "_tablespace" => 'fast_disk_array_3',
- "_engine" => 'InnoDB',
- });
+=item Arguments: @columns
-=head2 add_columns
+=item Return value: The ResultSource object
- $table->add_columns(qw/col1 col2 col3/);
+=back
- $table->add_columns('col1' => \%col1_info, 'col2' => \%col2_info, ...);
+ $source->add_columns(qw/col1 col2 col3/);
+ $source->add_columns('col1' => \%col1_info, 'col2' => \%col2_info, ...);
+
Adds columns to the result source. If supplied key => hashref pairs, uses
the hashref as the column_info for that column. Repeated calls of this
method will add more columns, not replace them.
@@ -161,10 +150,19 @@
=head2 add_column
- $table->add_column('col' => \%info?);
+=over
-Convenience alias to add_columns.
+=item Arguments: $colname, [ \%columninfo ]
+=item Return value: 1/0 (true/false)
+
+=back
+
+ $source->add_column('col' => \%info?);
+
+Add a single column and optional column info. Uses the same column
+info keys as L</add_columns>.
+
=cut
sub add_columns {
@@ -188,8 +186,16 @@
=head2 has_column
- if ($obj->has_column($col)) { ... }
+=over
+=item Arguments: $colname
+
+=item Return value: 1/0 (true/false)
+
+=back
+
+ if ($source->has_column($colname)) { ... }
+
Returns true if the source has a column of this name, false otherwise.
=cut
@@ -201,11 +207,20 @@
=head2 column_info
- my $info = $obj->column_info($col);
+=over
-Returns the column metadata hashref for a column. See the description
-of add_column for information on the contents of the hashref.
+=item Arguments: $colname
+=item Return value: Hashref of info
+
+=back
+
+ my $info = $source->column_info($col);
+
+Returns the column metadata hashref for a column, as originally passed
+to L</add_columns>. See the description of L</add_columns> for information
+on the contents of the hashref.
+
=cut
sub column_info {
@@ -238,20 +253,20 @@
return $self->_columns->{$column};
}
-=head2 column_info_from_storage
+=head2 columns
-Enables the on-demand automatic loading of the above column
-metadata from storage as neccesary. This is *deprecated*, and
-should not be used. It will be removed before 1.0.
+=over
- __PACKAGE__->column_info_from_storage(1);
+=item Arguments: None
-=head2 columns
+=item Return value: Ordered list of column names
- my @column_names = $obj->columns;
+=back
-Returns all column names in the order they were declared to add_columns.
+ my @column_names = $source->columns;
+Returns all column names in the order they were declared to L</add_columns>.
+
=cut
sub columns {
@@ -264,16 +279,41 @@
=head2 remove_columns
- $table->remove_columns(qw/col1 col2 col3/);
+=over
-Removes columns from the result source.
+=item Arguments: @colnames
+=item Return value: undefined
+
+=back
+
+ $source->remove_columns(qw/col1 col2 col3/);
+
+Removes the given list of columns by name, from the result source.
+
+B<Warning>: Removing a column that is also used in the sources primary
+key, or in one of the sources unique constraints, B<will> result in a
+broken result source.
+
=head2 remove_column
- $table->remove_column('col');
+=over
-Convenience alias to remove_columns.
+=item Arguments: $colname
+=item Return value: undefined
+
+=back
+
+ $source->remove_column('col');
+
+Remove a single column by name from the result source, similar to
+L</remove_columns>.
+
+B<Warning>: Removing a column that is also used in the sources primary
+key, or in one of the sources unique constraints, B<will> result in a
+broken result source.
+
=cut
sub remove_columns {
@@ -303,12 +343,15 @@
=item Arguments: @cols
+=item Return value: undefined
+
=back
Defines one or more columns as primary key for this source. Should be
-called after C<add_columns>.
+called after L</add_columns>.
-Additionally, defines a unique constraint named C<primary>.
+Additionally, defines a L<unique constraint|add_unique_constraint>
+named C<primary>.
The primary key columns are used by L<DBIx::Class::PK::Auto> to
retrieve automatically created values from the database.
@@ -329,8 +372,17 @@
=head2 primary_columns
-Read-only accessor which returns the list of primary keys.
+=over 4
+=item Arguments: None
+
+=item Return value: Ordered list of primary column names
+
+=back
+
+Read-only accessor which returns the list of primary keys, supplied by
+L</set_primary_key>.
+
=cut
sub primary_columns {
@@ -339,6 +391,14 @@
=head2 add_unique_constraint
+=over 4
+
+=item Arguments: [ $name ], \@colnames
+
+=item Return value: undefined
+
+=back
+
Declare a unique constraint on this source. Call once for each unique
constraint.
@@ -357,6 +417,9 @@
Unique constraints are used, for example, when you call
L<DBIx::Class::ResultSet/find>. Only columns in the constraint are searched.
+Throws an error if any of the given column names do not yet exist on
+the result source.
+
=cut
sub add_unique_constraint {
@@ -378,12 +441,29 @@
=head2 name_unique_constraint
-Return a name for a unique constraint containing the specified columns. These
-names consist of the table name and each column name, separated by underscores.
+=over 4
+=item Arguments: @colnames
+
+=item Return value: Constraint name
+
+=back
+
+ $source->table('mytable');
+ $source->name_unique_constraint('col1', 'col2');
+ # returns
+ 'mytable_col1_col2'
+
+Return a name for a unique constraint containing the specified
+columns. The name is created by joining the table name and each column
+name, using an underscore character.
+
For example, a constraint on a table named C<cd> containing the columns
C<artist> and C<title> would result in a constraint name of C<cd_artist_title>.
+This is used by L</add_unique_constraint> if you do not specify the
+optional constraint name.
+
=cut
sub name_unique_constraint {
@@ -394,8 +474,21 @@
=head2 unique_constraints
-Read-only accessor which returns the list of unique constraints on this source.
+=over 4
+=item Arguments: None
+
+=item Return value: Hash of unique constraint data
+
+=back
+
+ $source->unique_constraints();
+
+Read-only accessor which returns a hash of unique constraints on this source.
+
+The hash is keyed by constraint name, and contains an arrayref of
+column names as values.
+
=cut
sub unique_constraints {
@@ -404,6 +497,16 @@
=head2 unique_constraint_names
+=over 4
+
+=item Arguments: None
+
+=item Return value: Unique constraint names
+
+=back
+
+ $source->unique_constraint_names();
+
Returns the list of unique constraint names defined on this source.
=cut
@@ -418,6 +521,16 @@
=head2 unique_constraint_columns
+=over 4
+
+=item Arguments: $constraintname
+
+=item Return value: List of constraint columns
+
+=back
+
+ $source->unique_constraint_columns('myconstraint');
+
Returns the list of columns that make up the specified unique constraint.
=cut
@@ -434,19 +547,144 @@
return @{ $unique_constraints{$constraint_name} };
}
+=head2 resultset
+
+=over 4
+
+=item Arguments: None
+
+=item Return value: $resultset
+
+=back
+
+Returns a resultset for the given source. This will initially be created
+on demand by calling
+
+ $self->resultset_class->new($self, $self->resultset_attributes)
+
+but is cached from then on unless resultset_class changes.
+
+=head2 resultset_class
+
+=over 4
+
+=item Arguments: $classname
+
+=item Return value: $classname
+
+=back
+
+ package My::ResultSetClass;
+ use base 'DBIx::Class::ResultSet';
+ ...
+
+ $source->resultset_class('My::ResultSet::Class');
+
+Set the class of the resultset, this is useful if you want to create your
+own resultset methods. Create your own class derived from
+L<DBIx::Class::ResultSet>, and set it here. If called with no arguments,
+this method returns the name of the existing resultset class, if one
+exists.
+
+=head2 resultset_attributes
+
+=over 4
+
+=item Arguments: \%attrs
+
+=item Return value: \%attrs
+
+=back
+
+ $source->resultset_attributes({ order_by => [ 'id' ] });
+
+Store a collection of resultset attributes, that will be set on every
+L<DBIx::Class::ResultSet> produced from this result source. For a full
+list see L<DBIx::Class::ResultSet/ATTRIBUTES>.
+
+=cut
+
+sub resultset {
+ my $self = shift;
+ $self->throw_exception(
+ 'resultset does not take any arguments. If you want another resultset, '.
+ 'call it on the schema instead.'
+ ) if scalar @_;
+
+ return $self->resultset_class->new(
+ $self,
+ {
+ %{$self->{resultset_attributes}},
+ %{$self->schema->default_resultset_attributes}
+ },
+ );
+}
+
+=head2 source_name
+
+=over 4
+
+=item Arguments: $source_name
+
+=item Result value: $source_name
+
+=back
+
+Set an alternate name for the result source when it is loaded into a schema.
+This is useful if you want to refer to a result source by a name other than
+its class name.
+
+ package ArchivedBooks;
+ use base qw/DBIx::Class/;
+ __PACKAGE__->table('books_archive');
+ __PACKAGE__->source_name('Books');
+
+ # from your schema...
+ $schema->resultset('Books')->find(1);
+
=head2 from
+=over 4
+
+=item Arguments: None
+
+=item Return value: FROM clause
+
+=back
+
+ my $from_clause = $source->from();
+
Returns an expression of the source to be supplied to storage to specify
retrieval from this source. In the case of a database, the required FROM
clause contents.
=head2 schema
+=over 4
+
+=item Arguments: None
+
+=item Return value: A schema object
+
+=back
+
+ my $schema = $source->schema();
+
Returns the L<DBIx::Class::Schema> object that this result source
-belongs too.
+belongs to.
=head2 storage
+=over 4
+
+=item Arguments: None
+
+=item Return value: A Storage object
+
+=back
+
+ $source->storage->debug(1);
+
Returns the storage handle for the current schema.
See also: L<DBIx::Class::Storage>
@@ -457,8 +695,20 @@
=head2 add_relationship
+=over 4
+
+=item Arguments: $relname, $related_source_name, \%cond, [ \%attrs ]
+
+=item Return value: 1/true if it succeeded
+
+=back
+
$source->add_relationship('relname', 'related_source', $cond, $attrs);
+L<DBIx::Class::Relationship> describes a series of methods which
+create pre-defined useful types of relationships. Look there first
+before using this method directly.
+
The relationship name can be arbitrary, but must be unique for each
relationship attached to this result source. 'related_source' should
be the name with which the related result source was registered with
@@ -470,7 +720,7 @@
The condition C<$cond> needs to be an L<SQL::Abstract>-style
representation of the join between the tables. For example, if you're
-creating a rel from Author to Book,
+creating a relation from Author to Book,
{ 'foreign.author_id' => 'self.id' }
@@ -517,6 +767,9 @@
=back
+Throws an exception if the condition is improperly supplied, or cannot
+be resolved using L</resolve_join>.
+
=cut
sub add_relationship {
@@ -567,6 +820,16 @@
=head2 relationships
+=over 4
+
+=item Arguments: None
+
+=item Return value: List of relationship names
+
+=back
+
+ my @relnames = $source->relationships();
+
Returns all relationship names for this source.
=cut
@@ -581,10 +844,12 @@
=item Arguments: $relname
+=item Return value: Hashref of relation data,
+
=back
Returns a hash of relationship information for the specified relationship
-name.
+name. The keys/values are as specified for L</add_relationship>.
=cut
@@ -599,6 +864,8 @@
=item Arguments: $rel
+=item Return value: 1/0 (true/false)
+
=back
Returns true if the source has a relationship of this name, false otherwise.
@@ -616,11 +883,22 @@
=item Arguments: $relname
+=item Return value: Hashref of relationship data
+
=back
-Returns an array of hash references of relationship information for
-the other side of the specified relationship name.
+Looks through all the relationships on the source this relationship
+points to, looking for one whose condition is the reverse of the
+condition on this relationship.
+A common use of this is to find the name of the C<belongs_to> relation
+opposing a C<has_many> relation. For definition of these look in
+L<DBIx::Class::Relationship>.
+
+The returned hashref is keyed by the name of the opposing
+relationship, and contains it's data in the same manner as
+L</relationship_info>.
+
=cut
sub reverse_relationship_info {
@@ -676,8 +954,10 @@
=over 4
-=item Arguments: $keys1, $keys2
+=item Arguments: \@keys1, \@keys2
+=item Return value: 1/0 (true/false)
+
=back
Returns true if both sets of keynames are the same, false otherwise.
@@ -717,12 +997,36 @@
return $found;
}
+=head2 sqlt_deploy_hook
+
+=over 4
+
+=item Arguments: $source, $sqlt_table
+
+=item Return value: undefined
+
+=back
+
+This is NOT a method of C<ResultSource>.
+
+An optional sub which you can declare in your own Result class that will get
+passed the L<SQL::Translator::Schema::Table> object when you deploy the schema
+via L</create_ddl_dir> or L</deploy>.
+
+This is useful to make L<SQL::Translator> create non-unique indexes,
+or set table options such as C<Engine=INNOFB>.
+
+For an example of what you can do with this, see
+L<DBIx::Class::Manual::Cookbook/Adding Indexes And Functions To Your SQL>.
+
=head2 resolve_join
=over 4
=item Arguments: $relation
+=item Return value: Join condition arrayref
+
=back
Returns the join structure required for the related result source.
@@ -774,6 +1078,8 @@
=item Arguments: $relname, $rel_data
+=item Return value: 1/0 (true/false)
+
=back
Determines whether a relation is dependent on an object from this source
@@ -1000,6 +1306,8 @@
=item Arguments: $relname
+=item Return value: $source
+
=back
Returns the result source object for the given relationship.
@@ -1020,6 +1328,8 @@
=item Arguments: $relname
+=item Return value: $classname
+
=back
Returns the class name for objects in the given relationship.
@@ -1034,75 +1344,6 @@
return $self->schema->class($self->relationship_info($rel)->{source});
}
-=head2 resultset
-
-Returns a resultset for the given source. This will initially be created
-on demand by calling
-
- $self->resultset_class->new($self, $self->resultset_attributes)
-
-but is cached from then on unless resultset_class changes.
-
-=head2 resultset_class
-
-` package My::ResultSetClass;
- use base 'DBIx::Class::ResultSet';
- ...
-
- $source->resultset_class('My::ResultSet::Class');
-
-Set the class of the resultset, this is useful if you want to create your
-own resultset methods. Create your own class derived from
-L<DBIx::Class::ResultSet>, and set it here. If called with no arguments,
-this method returns the name of the existing resultset class, if one
-exists.
-
-=head2 resultset_attributes
-
- $source->resultset_attributes({ order_by => [ 'id' ] });
-
-Specify here any attributes you wish to pass to your specialised
-resultset. For a full list of these, please see
-L<DBIx::Class::ResultSet/ATTRIBUTES>.
-
-=cut
-
-sub resultset {
- my $self = shift;
- $self->throw_exception(
- 'resultset does not take any arguments. If you want another resultset, '.
- 'call it on the schema instead.'
- ) if scalar @_;
-
- return $self->resultset_class->new(
- $self,
- {
- %{$self->{resultset_attributes}},
- %{$self->schema->default_resultset_attributes}
- },
- );
-}
-
-=head2 source_name
-
-=over 4
-
-=item Arguments: $source_name
-
-=back
-
-Set the name of the result source when it is loaded into a schema.
-This is usefull if you want to refer to a result source by a name other than
-its class name.
-
- package ArchivedBooks;
- use base qw/DBIx::Class/;
- __PACKAGE__->table('books_archive');
- __PACKAGE__->source_name('Books');
-
- # from your schema...
- $schema->resultset('Books')->find(1);
-
=head2 handle
Obtain a new handle to this source. Returns an instance of a
@@ -1132,15 +1373,43 @@
}
}
-=head2 sqlt_deploy_hook($sqlt_table)
+=head2 source_info
-An optional sub which you can declare in your own Schema class that will get
-passed the L<SQL::Translator::Schema::Table> object when you deploy the schema
-via L</create_ddl_dir> or L</deploy>.
+Stores a hashref of per-source metadata. No specific key names
+have yet been standardized, the examples below are purely hypothetical
+and don't actually accomplish anything on their own:
-For an example of what you can do with this, see
-L<DBIx::Class::Manual::Cookbook/Adding Indexes And Functions To Your SQL>.
+ __PACKAGE__->source_info({
+ "_tablespace" => 'fast_disk_array_3',
+ "_engine" => 'InnoDB',
+ });
+=head2 new
+
+ $class->new();
+
+ $class->new({attribute_name => value});
+
+Creates a new ResultSource object. Not normally called directly by end users.
+
+=cut
+
+=head2 column_info_from_storage
+
+=over
+
+=item Arguments: 1/0 (default: 0)
+
+=item Return value: 1/0
+
+=back
+
+Enables the on-demand automatic loading of the above column
+metadata from storage as neccesary. This is *deprecated*, and
+should not be used. It will be removed before 1.0.
+
+ __PACKAGE__->column_info_from_storage(1);
+
=head1 AUTHORS
Matt S. Trout <mst at shadowcatsystems.co.uk>
Modified: DBIx-Class/0.08/branches/sqla_1.50_compat/lib/DBIx/Class/ResultSourceProxy/Table.pm
===================================================================
--- DBIx-Class/0.08/branches/sqla_1.50_compat/lib/DBIx/Class/ResultSourceProxy/Table.pm 2009-01-18 00:44:43 UTC (rev 5317)
+++ DBIx-Class/0.08/branches/sqla_1.50_compat/lib/DBIx/Class/ResultSourceProxy/Table.pm 2009-01-18 19:40:39 UTC (rev 5318)
@@ -40,11 +40,6 @@
$class->result_source_instance($table);
- if ($class->can('schema_instance') && $class->schema_instance) {
- $class =~ m/([^:]+)$/;
- $class->schema_instance->register_class($class, $class);
- }
-
return $table;
}
@@ -95,10 +90,6 @@
$class->result_source_instance($table);
- if ($class->can('schema_instance')) {
- $class =~ m/([^:]+)$/;
- $class->schema_instance->register_class($class, $class);
- }
return $class->result_source_instance->name;
}
Modified: DBIx-Class/0.08/branches/sqla_1.50_compat/lib/DBIx/Class/Row.pm
===================================================================
--- DBIx-Class/0.08/branches/sqla_1.50_compat/lib/DBIx/Class/Row.pm 2009-01-18 00:44:43 UTC (rev 5317)
+++ DBIx-Class/0.08/branches/sqla_1.50_compat/lib/DBIx/Class/Row.pm 2009-01-18 19:40:39 UTC (rev 5318)
@@ -450,6 +450,14 @@
database-level cascade or restrict will take precedence over a
DBIx-Class-based cascading delete.
+If you delete an object within a txn_do() (see L<DBIx::Class::Storage/txn_do>)
+and the transaction subsequently fails, the row object will remain marked as
+not being in storage. If you know for a fact that the object is still in
+storage (i.e. by inspecting the cause of the transaction's failure), you can
+use C<< $obj->in_storage(1) >> to restore consistency between the object and
+the database. This would allow a subsequent C<< $obj->delete >> to work
+as expected.
+
See also L<DBIx::Class::ResultSet/delete>.
=cut
Modified: DBIx-Class/0.08/branches/sqla_1.50_compat/lib/DBIx/Class/Schema.pm
===================================================================
--- DBIx-Class/0.08/branches/sqla_1.50_compat/lib/DBIx/Class/Schema.pm 2009-01-18 00:44:43 UTC (rev 5317)
+++ DBIx-Class/0.08/branches/sqla_1.50_compat/lib/DBIx/Class/Schema.pm 2009-01-18 19:40:39 UTC (rev 5318)
@@ -211,7 +211,6 @@
foreach my $result (keys %results) {
my $result_class = $results{$result};
$class->ensure_class_loaded($result_class);
- $result_class->source_name($result) unless $result_class->source_name;
my $rs_class = delete $resultsets{$result};
my $rs_set = $result_class->resultset_class;
@@ -226,7 +225,9 @@
$result_class->resultset_class($rs_class);
}
- push(@to_register, [ $result_class->source_name, $result_class ]);
+ my $source_name = $result_class->source_name || $result;
+
+ push(@to_register, [ $source_name, $result_class ]);
}
}
@@ -1228,7 +1229,7 @@
sub _register_source {
my ($self, $moniker, $source, $params) = @_;
- %$source = %{ $source->new( { %$source, source_name => $moniker }) };
+ $source = $source->new({ %$source, source_name => $moniker });
my %reg = %{$self->source_registrations};
$reg{$moniker} = $source;
Modified: DBIx-Class/0.08/branches/sqla_1.50_compat/lib/DBIx/Class/Storage/DBI/Pg.pm
===================================================================
--- DBIx-Class/0.08/branches/sqla_1.50_compat/lib/DBIx/Class/Storage/DBI/Pg.pm 2009-01-18 00:44:43 UTC (rev 5317)
+++ DBIx-Class/0.08/branches/sqla_1.50_compat/lib/DBIx/Class/Storage/DBI/Pg.pm 2009-01-18 19:40:39 UTC (rev 5318)
@@ -70,6 +70,7 @@
my $bind_attributes = {
bytea => { pg_type => DBD::Pg::PG_BYTEA },
+ blob => { pg_type => DBD::Pg::PG_BYTEA },
};
if( defined $bind_attributes->{$data_type} ) {
Modified: DBIx-Class/0.08/branches/sqla_1.50_compat/lib/DBIx/Class/Storage/DBI.pm
===================================================================
--- DBIx-Class/0.08/branches/sqla_1.50_compat/lib/DBIx/Class/Storage/DBI.pm 2009-01-18 00:44:43 UTC (rev 5317)
+++ DBIx-Class/0.08/branches/sqla_1.50_compat/lib/DBIx/Class/Storage/DBI.pm 2009-01-18 19:40:39 UTC (rev 5318)
@@ -893,11 +893,11 @@
}
}
+ $self->_conn_pid($$);
+ $self->_conn_tid(threads->tid) if $INC{'threads.pm'};
+
my $connection_do = $self->on_connect_do;
$self->_do_connection_actions($connection_do) if ref($connection_do);
-
- $self->_conn_pid($$);
- $self->_conn_tid(threads->tid) if $INC{'threads.pm'};
}
sub _do_connection_actions {
@@ -908,7 +908,7 @@
$self->_do_query($_) foreach @$connection_do;
}
elsif (ref $connection_do eq 'CODE') {
- $connection_do->();
+ $connection_do->($self);
}
return $self;
Modified: DBIx-Class/0.08/branches/sqla_1.50_compat/lib/DBIx/Class.pm
===================================================================
--- DBIx-Class/0.08/branches/sqla_1.50_compat/lib/DBIx/Class.pm 2009-01-18 00:44:43 UTC (rev 5317)
+++ DBIx-Class/0.08/branches/sqla_1.50_compat/lib/DBIx/Class.pm 2009-01-18 19:40:39 UTC (rev 5318)
@@ -287,6 +287,8 @@
ribasushi: Peter Rabbitson <rabbit at rabbit.us>
+rjbs: Ricardo Signes <rjbs at cpan.org>
+
sc_: Just Another Perl Hacker
scotty: Scotty Allen <scotty at scottyallen.com>
@@ -311,6 +313,8 @@
zamolxes: Bogdan Lucaciu <bogdan at wiz.ro>
+norbi: Norbert Buchmuller <norbi at nix.hu>
+
=head1 LICENSE
You may distribute this code under the same terms as Perl itself.
Modified: DBIx-Class/0.08/branches/sqla_1.50_compat/t/39load_namespaces_1.t
===================================================================
--- DBIx-Class/0.08/branches/sqla_1.50_compat/t/39load_namespaces_1.t 2009-01-18 00:44:43 UTC (rev 5317)
+++ DBIx-Class/0.08/branches/sqla_1.50_compat/t/39load_namespaces_1.t 2009-01-18 19:40:39 UTC (rev 5318)
@@ -6,7 +6,7 @@
unshift(@INC, './t/lib');
-plan tests => 6;
+plan tests => 8;
my $warnings;
eval {
@@ -27,3 +27,8 @@
isa_ok($source_b, 'DBIx::Class::ResultSource::Table');
my $rset_b = DBICNSTest->resultset('B');
isa_ok($rset_b, 'DBIx::Class::ResultSet');
+
+for my $moniker (qw/A B/) {
+ my $class = "DBICNSTest::Result::$moniker";
+ ok(!defined($class->result_source_instance->source_name));
+}
Modified: DBIx-Class/0.08/branches/sqla_1.50_compat/t/76select.t
===================================================================
--- DBIx-Class/0.08/branches/sqla_1.50_compat/t/76select.t 2009-01-18 00:44:43 UTC (rev 5317)
+++ DBIx-Class/0.08/branches/sqla_1.50_compat/t/76select.t 2009-01-18 19:40:39 UTC (rev 5318)
@@ -8,7 +8,7 @@
my $schema = DBICTest->init_schema();
-plan tests => 11;
+plan tests => 12;
my $rs = $schema->resultset('CD')->search({},
{
@@ -61,3 +61,5 @@
is ($subsel->count, 2, 'Subselect correctly limited the rs to 2 cds');
is ($subsel->next->title, $cds->next->title, 'First CD title match');
is ($subsel->next->title, $cds->next->title, 'Second CD title match');
+
+is($schema->resultset('CD')->current_source_alias, "me", '$rs->current_source_alias returns "me"');
Modified: DBIx-Class/0.08/branches/sqla_1.50_compat/t/92storage_on_connect_do.t
===================================================================
--- DBIx-Class/0.08/branches/sqla_1.50_compat/t/92storage_on_connect_do.t 2009-01-18 00:44:43 UTC (rev 5317)
+++ DBIx-Class/0.08/branches/sqla_1.50_compat/t/92storage_on_connect_do.t 2009-01-18 19:40:39 UTC (rev 5318)
@@ -1,7 +1,7 @@
use strict;
use warnings;
-use Test::More tests => 9;
+use Test::More tests => 10;
use lib qw(t/lib);
use base 'DBICTest';
@@ -33,11 +33,11 @@
$schema->storage->disconnect();
-my($connected, $disconnected);
+my($connected, $disconnected, @cb_args);
ok $schema->connection(
DBICTest->_database,
{
- on_connect_do => sub { $connected = 1 },
+ on_connect_do => sub { $connected = 1; @cb_args = @_; },
on_disconnect_do => sub { $disconnected = 1 },
},
), 'second connection()';
@@ -47,6 +47,7 @@
$schema->storage->disconnect();
ok $disconnected, 'on_disconnect_do() called after disconnect()';
+isa_ok($cb_args[0], 'DBIx::Class::Storage', 'first arg to on_connect_do hook');
sub check_exists {
my $storage = shift;
More information about the Bast-commits
mailing list