[SCM] Debian packaging of libdbix-class-perl branch, master, updated. debian/0.08195-1-31-g40a754e
gregor herrmann
gregoa at debian.org
Fri May 17 18:20:12 UTC 2013
The following commit has been merged in the master branch:
commit 8debc4736b5a222eff47000651e7c82851eeaa8c
Merge: 1349a8025ec584ff51467365d57a18a20bbf0f13 6cdb88ad539f85aa234b4c295a86f7221410a255
Author: gregor herrmann <gregoa at debian.org>
Date: Fri May 17 18:59:27 2013 +0200
Merge tag 'upstream/0.08250'
Upstream version 0.08250
diff --combined lib/DBIx/Class/Manual/Cookbook.pod
index 47f55a4,588c315..7605619
--- a/lib/DBIx/Class/Manual/Cookbook.pod
+++ b/lib/DBIx/Class/Manual/Cookbook.pod
@@@ -117,7 -117,12 +117,12 @@@ almost like you would define a regular
__PACKAGE__->table_class('DBIx::Class::ResultSource::View');
- # ->table, ->add_columns, etc.
+ # For the time being this is necessary even for virtual views
+ __PACKAGE__->table($view_name);
+
+ #
+ # ->add_columns, etc.
+ #
# do not attempt to deploy() this view
__PACKAGE__->result_source_instance->is_virtual(1);
@@@ -349,8 -354,8 +354,8 @@@ from, select, and +select attributes
my $rs = $cdrs->search({
year => {
'=' => $cdrs->search(
- { artist_id => { '=' => { -ident => 'me.artist_id' } } },
- { alias => 'inner' }
+ { artist_id => { -ident => 'me.artist_id' } },
+ { alias => 'sub_query' }
)->get_column('year')->max_rs->as_query,
},
});
@@@ -359,11 -364,11 +364,11 @@@ That creates the following SQL
SELECT me.cdid, me.artist, me.title, me.year, me.genreid, me.single_track
FROM cd me
- WHERE year = (
- SELECT MAX(inner.year)
- FROM cd inner
- WHERE artist_id = me.artist_id
- )
+ WHERE year = (
+ SELECT MAX(sub_query.year)
+ FROM cd sub_query
+ WHERE artist_id = me.artist_id
+ )
=head2 Predefined searches
@@@ -416,30 -421,59 +421,59 @@@ you create an index on the return valu
it can be accomplished with C<DBIx::Class> when necessary by resorting to
literal SQL:
- $rs->search(\[ 'YEAR(date_of_birth) = ?', [ plain_value => 1979 ] ]);
+ $rs->search(
+ \[ 'YEAR(date_of_birth) = ?', 1979 ]
+ );
# Equivalent SQL:
# SELECT * FROM employee WHERE YEAR(date_of_birth) = ?
+ To include the function as part of a larger search, use the '-and' keyword
+ to collect the search conditions:
+
$rs->search({ -and => [
name => 'Bob',
- \[ 'YEAR(date_of_birth) = ?', [ plain_value => 1979 ] ],
+ \[ 'YEAR(date_of_birth) = ?', 1979 ]
]});
# Equivalent SQL:
# SELECT * FROM employee WHERE name = ? AND YEAR(date_of_birth) = ?
- Note: the C<plain_value> string in the C<< [ plain_value => 1979 ] >> part
- should be either the same as the name of the column (do this if the type of the
- return value of the function is the same as the type of the column) or in the
- case of a function it's currently treated as a dummy string (it is a good idea
- to use C<plain_value> or something similar to convey intent). The value is
- currently only significant when handling special column types (BLOBs, arrays,
- etc.), but this may change in the future.
+ Note: the syntax for specifying the bind value's datatype and value is
+ explained in L<DBIx::Class::ResultSet/DBIC BIND VALUES>.
See also L<SQL::Abstract/Literal SQL with placeholders and bind values
(subqueries)>.
+ =head2 Software Limits
+
+ When your RDBMS does not have a working SQL limit mechanism (e.g. Sybase ASE)
+ and L<GenericSubQ|SQL::Abstract::Limit/GenericSubQ> is either too slow or does
+ not work at all, you can try the
+ L<software_limit|DBIx::Class::ResultSet/software_limit>
+ L<DBIx::Class::ResultSet> attribute, which skips over records to simulate limits
+ in the Perl layer.
+
+ For example:
+
+ my $paged_rs = $rs->search({}, {
+ rows => 25,
+ page => 3,
+ order_by => [ 'me.last_name' ],
+ software_limit => 1,
+ });
+
+ You can set it as a default for your schema by placing the following in your
+ C<Schema.pm>:
+
+ __PACKAGE__->default_resultset_attributes({ software_limit => 1 });
+
+ B<WARNING:> If you are dealing with large resultsets and your L<DBI> or
+ ODBC/ADO driver does not have proper cursor support (i.e. it loads the whole
+ resultset into memory) then this feature will be extremely slow and use huge
+ amounts of memory at best, and may cause your process to run out of memory and
+ cause instability on your server at worst, beware!
+
=head1 JOINS AND PREFETCHING
=head2 Using joins and prefetch
@@@ -570,7 -604,7 +604,7 @@@ C<LinerNotes>
# SELECT cd.*, artist.*, liner_notes.* FROM cd
# JOIN artist ON cd.artist = artist.id
# JOIN liner_notes ON cd.id = liner_notes.cd
- # WHERE artist.name = 'Bob Marley'
+ # WHERE artist.name = 'Bob Marley' AND liner_notes.notes LIKE '%some text%'
# ORDER BY artist.name
=head2 Multi-step joins
@@@ -683,9 -717,9 +717,9 @@@ SQL statements
=head1 ROW-LEVEL OPERATIONS
- =head2 Retrieving a row object's Schema
+ =head2 Retrieving a result object's Schema
- It is possible to get a Schema object from a row object like so:
+ It is possible to get a Schema object from a result object like so:
my $schema = $cd->result_source->schema;
# use the schema as normal:
@@@ -930,7 -964,7 +964,7 @@@ B<Test File> test.p
Alternatively you can use L<DBIx::Class::DynamicSubclass> that implements
exactly the above functionality.
- =head2 Skip row object creation for faster results
+ =head2 Skip result object creation for faster results
DBIx::Class is not built for speed, it's built for convenience and
ease of use, but sometimes you just need to get the data, and skip the
@@@ -1029,7 -1063,7 +1063,7 @@@ See L<DBIx::Class::ResultSetColumn> fo
=head2 Creating a result set from a set of rows
- Sometimes you have a (set of) row objects that you want to put into a
+ Sometimes you have a (set of) result objects that you want to put into a
resultset without the need to hit the DB again. You can do that by using the
L<set_cache|DBIx::Class::Resultset/set_cache> method:
@@@ -1189,7 -1223,7 +1223,7 @@@ building a renaming facility, like so
1;
-By overridding the L<connection|DBIx::Class::Schama/connection>
+By overriding the L<connection|DBIx::Class::Schama/connection>
method and extracting a custom option from the provided \%attr hashref one can
then simply iterate over all the Schema's ResultSources, renaming them as
needed.
@@@ -1323,9 -1357,9 +1357,9 @@@ row
});
} catch {
$exception = $_;
- }
+ };
- if ($caught) {
+ if ($exception) {
# There was an error while handling the $job. Rollback all changes
# since the transaction started, including the already committed
# ('released') savepoints. There will be neither a new $job nor any
@@@ -1907,8 -1941,9 +1941,9 @@@ just looking for this
For example, say that you have three columns, C<id>, C<number>, and
C<squared>. You would like to make changes to C<number> and have
C<squared> be automagically set to the value of C<number> squared.
- You can accomplish this by wrapping the C<number> accessor with
- L<Class::Method::Modifiers>:
+ You can accomplish this by wrapping the C<number> accessor with the C<around>
+ method modifier, available through either L<Class::Method::Modifiers>,
+ L<Moose|Moose::Manual::MethodModifiers> or L<Moose-like|Moo> modules):
around number => sub {
my ($orig, $self) = (shift, shift);
@@@ -1919,7 -1954,7 +1954,7 @@@
}
$self->$orig(@_);
- }
+ };
Note that the hard work is done by the call to C<< $self->$orig >>, which
redispatches your call to store_column in the superclass(es).
@@@ -2128,8 -2163,8 +2163,8 @@@ L</Using joins and prefetch>
=item *
Use L<populate|DBIx::Class::ResultSet/populate> in void context to insert data
- when you don't need the resulting L<DBIx::Class::Row> objects, if possible, but
- see the caveats.
+ when you don't need the resulting L<result|DBIx::Class::Manual::ResultClass> objects,
+ if possible, but see the caveats.
When inserting many rows, for best results, populate a large number of rows at a
time, but not so large that the table is locked for an unacceptably long time.
diff --combined lib/DBIx/Class/Manual/FAQ.pod
index 6d58c16,7f063b7..21b1b3a
--- a/lib/DBIx/Class/Manual/FAQ.pod
+++ b/lib/DBIx/Class/Manual/FAQ.pod
@@@ -75,7 -75,7 +75,7 @@@ lot later
=item .. use DBIx::Class across multiple databases?
-If your database server allows you to run querys across multiple
+If your database server allows you to run queries across multiple
databases at once, then so can DBIx::Class. All you need to do is make
sure you write the database name as part of the
L<DBIx::Class::ResultSource/table> call. Eg:
@@@ -134,8 -134,8 +134,8 @@@ as you like. See L<DBIx::Class::Relatio
=item .. define a relationship bridge across an intermediate table? (many-to-many)
- The term 'relationship' is used loosely with many_to_many as it is not considered a
- relationship in the fullest sense. For more info, read the documentation on L<DBIx::Class::Relationship/many_to_many>.
+ The term 'relationship' is used loosely with many_to_many as it is not considered a
+ relationship in the fullest sense. For more info, read the documentation on L<DBIx::Class::Relationship/many_to_many>.
=item .. stop DBIx::Class from attempting to cascade deletes on my has_many and might_have relationships?
@@@ -242,15 -242,7 +242,7 @@@ documentation for details
To use an SQL function on the left hand side of a comparison you currently need
to resort to literal SQL:
- ->search( \[ 'YEAR(date_of_birth) = ?', [ plain_value => 1979 ] ] );
-
- Note: the C<plain_value> string in the C<< [ plain_value => 1979 ] >> part
- should be either the same as the name of the column (do this if the type of the
- return value of the function is the same as the type of the column) or in the
- case of a function it's currently treated as a dummy string (it is a good idea
- to use C<plain_value> or something similar to convey intent). The value is
- currently only significant when handling special column types (BLOBs, arrays,
- etc.), but this may change in the future.
+ ->search( \[ 'YEAR(date_of_birth) = ?', 1979 ] );
=item .. find more help on constructing searches?
@@@ -304,7 -296,7 +296,7 @@@ Use the L<DBIx::Class::ResultSet/rows>
L<DBIx::Class::ResultSet/order_by> attributes to order your data and
pick off a single row.
- See also L<DBIx::Class::Manual::Cookbook/Retrieve_one_and_only_one_row_from_a_resultset>.
+ See also L<DBIx::Class::Manual::Cookbook/Retrieve one and only one row from a resultset>.
A less readable way is to ask a regular search to return 1 row, using
L<DBIx::Class::ResultSet/slice>:
@@@ -322,7 -314,7 +314,7 @@@ Use L<DBIx::Class::Row/discard_changes>
$row->discard_changes
-Discarding changes and refreshing from storage are two sides fo the same coin. When you
+Discarding changes and refreshing from storage are two sides of the same coin. When you
want to discard your local changes, just re-fetch the row from storage. When you want
to get a new, fresh copy of the row, just re-fetch the row from storage.
L<DBIx::Class::Row/discard_changes> does just that by re-fetching the row from storage
@@@ -351,7 -343,7 +343,7 @@@ C<count> on the resultset will only ret
=item .. insert a row with an auto incrementing primary key?
This happens automatically. After
- L<creating|DBIx::Class::ResultSet/create> a row object, the primary
+ L<creating|DBIx::Class::ResultSet/create> a result object, the primary
key value created by your database can be fetched by calling C<id> (or
the access of your primary key column) on the object.
@@@ -437,8 -429,8 +429,8 @@@ data out
=head2 Custom methods in Result classes
- You can add custom methods that do arbitrary things, even to unrelated tables.
- For example, to provide a C<< $book->foo() >> method which searches the
+ You can add custom methods that do arbitrary things, even to unrelated tables.
+ For example, to provide a C<< $book->foo() >> method which searches the
cd table, you'd could add this to Book.pm:
sub foo {
@@@ -455,7 -447,7 +447,7 @@@ methods to find or create data in relat
write your own methods, you can.
For example, to provide a C<< $book->foo() >> method to manually implement
- what create_related() from L<DBIx::Class::Relationship::Base> does, you could
+ what create_related() from L<DBIx::Class::Relationship::Base> does, you could
add this to Book.pm:
sub foo {
@@@ -536,7 -528,7 +528,7 @@@ L<DBIx::Class> runs the actual SQL stat
if you create a resultset using C<search> in scalar context, no query
is executed. You can create further resultset refinements by calling
search again or relationship accessors. The SQL query is only run when
- you ask the resultset for an actual row object.
+ you ask the resultset for an actual result object.
=item How do I deal with tables that lack a primary key?
@@@ -556,7 -548,7 +548,7 @@@ Look at the tips in L<DBIx::Class::Manu
=item How do I reduce the overhead of database queries?
You can reduce the overhead of object creation within L<DBIx::Class>
- using the tips in L<DBIx::Class::Manual::Cookbook/"Skip row object creation for faster results">
+ using the tips in L<DBIx::Class::Manual::Cookbook/"Skip result object creation for faster results">
and L<DBIx::Class::Manual::Cookbook/"Get raw data for blindingly fast results">
=item How do I override a run time method (e.g. a relationship accessor)?
@@@ -567,12 -559,12 +559,12 @@@ The code example works for both modules
package Your::Schema::Group;
use Class::Method::Modifiers;
-
+
# ... declare columns ...
-
+
__PACKAGE__->has_many('group_servers', 'Your::Schema::GroupServer', 'group_id');
__PACKAGE__->many_to_many('servers', 'group_servers', 'server');
-
+
# if the server group is a "super group", then return all servers
# otherwise return only servers that belongs to the given group
around 'servers' => sub {
@@@ -592,12 -584,12 +584,12 @@@ L<Method::Signatures::Simple> way
package Your::Schema::Group;
use Method::Signatures::Simple;
-
+
# ... declare columns ...
-
+
__PACKAGE__->has_many('group_servers', 'Your::Schema::GroupServer', 'group_id');
__PACKAGE__->many_to_many('servers', 'group_servers', 'server');
-
+
# The method keyword automatically injects the annoying my $self = shift; for you.
method servers {
return $self->result_source->schema->resultset('Server')->search({ ... });
@@@ -607,17 -599,17 +599,17 @@@ The dirty way
package Your::Schema::Group;
use Sub::Name;
-
+
# ... declare columns ...
-
+
__PACKAGE__->has_many('group_servers', 'Your::Schema::GroupServer', 'group_id');
__PACKAGE__->many_to_many('servers', 'group_servers', 'server');
-
+
*servers = subname servers => sub {
my $self = shift;
return $self->result_source->schema->resultset('Server')->search({ ... });
};
-
+
=back
=head2 Notes for CDBI users
diff --combined lib/DBIx/Class/Manual/Features.pod
index bebcddf,7c7d5c6..73703d4
--- a/lib/DBIx/Class/Manual/Features.pod
+++ b/lib/DBIx/Class/Manual/Features.pod
@@@ -254,11 -254,11 +254,11 @@@ Create a DBIx::Class schema from your d
my $schema = Frew::Schema->connect( $dsn, $user, $pass );
- See L<DBIx::Class::Schema::Loader> and L<DBIx::Class::Schema::Loader::Base/CONSTRUCTOR_OPTIONS>.
+ See L<DBIx::Class::Schema::Loader> and L<DBIx::Class::Schema::Loader::Base/CONSTRUCTOR OPTIONS>.
=head2 Populate
-Made for inserting lots of rows very quicky into database
+Made for inserting lots of rows very quickly into database
$schema->populate([ Users =>
[qw( username password )],
@@@ -274,7 -274,7 +274,7 @@@ I use populate L<here|http://blog.afool
=head2 Multicreate
-Create an object and it's related objects all at once
+Create an object and its related objects all at once
$schema->resultset('Author')->create({
name => 'Stephen King',
diff --combined lib/DBIx/Class/Manual/Joining.pod
index f7adf83,5785349..8044b74
--- a/lib/DBIx/Class/Manual/Joining.pod
+++ b/lib/DBIx/Class/Manual/Joining.pod
@@@ -1,4 -1,4 +1,4 @@@
- =head1 NAME
+ =head1 NAME
DBIx::Class::Manual::Joining - Manual on joining tables with DBIx::Class
@@@ -17,12 -17,12 +17,12 @@@ instead. Skip this part if you know wha
But I'll explain anyway. Assuming you have created your database in a
more or less sensible way, you will end up with several tables that
contain C<related> information. For example, you may have a table
-containing information about C<CD>s, containing the CD title and it's
+containing information about C<CD>s, containing the CD title and its
year of publication, and another table containing all the C<Track>s
for the CDs, one track per row.
When you wish to extract information about a particular CD and all
-it's tracks, You can either fetch the CD row, then make another query
+its tracks, You can either fetch the CD row, then make another query
to fetch the tracks, or you can use a join. Compare:
SELECT ID, Title, Year FROM CD WHERE Title = 'Funky CD';
@@@ -164,7 -164,7 +164,7 @@@ object will have no 'track_name' access
Instead C<get_column> must be used:
while(my $row = $search_rs->next) {
- print $row->get_colum('track_name'); ## WORKS
+ print $row->get_column('track_name'); ## WORKS
}
=head2 Incomplete related objects
@@@ -175,14 -175,14 +175,14 @@@ has a very large field you don't need f
output. This is better solved by storing that field in a separate
table which you only join to when needed.
- To fetch an incomplete related object, supply the dotted notation to the '+as' attribute:
+ To fetch an incomplete related object, supply the dotted notation to the '+as' attribute:
$schema->resultset('CD')->search(
{ 'Title' => 'Funky CD',
},
{ join => 'tracks',
'+select' => ['tracks.Name'],
- '+as' => ['tracks.Name'],
+ '+as' => ['tracks.Name'],
order_by => ['tracks.id'],
}
);
@@@ -232,13 -232,13 +232,13 @@@ Which is
To perform joins using relations of the tables you are joining to, use
a hashref to indicate the join depth. This can theoretically go as
- deep as you like (warning: contrived examples!):
+ deep as you like (warning: contrived examples!):
join => { room => { table => 'leg' } }
To join two relations at the same level, use an arrayref instead:
- join => { room => [ 'chair', 'table' ] }
+ join => { room => [ 'chair', 'table' ] }
Or combine the two:
diff --combined lib/DBIx/Class/Optional/Dependencies.pm
index 92cae5c,16f88be..e1782a0
--- a/lib/DBIx/Class/Optional/Dependencies.pm
+++ b/lib/DBIx/Class/Optional/Dependencies.pm
@@@ -32,6 -32,13 +32,13 @@@ my $admin_basic =
'namespace::autoclean' => '0.09',
};
+ my $admin_script = {
+ %$moose_basic,
+ %$admin_basic,
+ 'Getopt::Long::Descriptive' => '0.081',
+ 'Text::CSV' => '1.16',
+ };
+
my $datetime_basic = {
'DateTime' => '0.55',
'DateTime::Format::Strptime' => '1.2',
@@@ -99,10 -106,6 +106,6 @@@ my $rdbms_firebird_odbc =
};
my $reqs = {
- dist => {
- #'Module::Install::Pod::Inherit' => '0.01',
- },
-
replicated => {
req => $replicated,
pod => {
@@@ -131,10 -134,7 +134,7 @@@
admin_script => {
req => {
- %$moose_basic,
- %$admin_basic,
- 'Getopt::Long::Descriptive' => '0.081',
- 'Text::CSV' => '1.16',
+ %$admin_script,
},
pod => {
title => 'dbicadmin',
@@@ -144,7 -144,7 +144,7 @@@
deploy => {
req => {
- 'SQL::Translator' => '0.11006',
+ 'SQL::Translator' => '0.11016',
},
pod => {
title => 'Storage::DBI::deploy()',
@@@ -164,7 -164,7 +164,7 @@@
test_pod => {
req => {
- 'Test::Pod' => '1.41',
+ 'Test::Pod' => '1.42',
},
},
@@@ -175,15 -175,16 +175,16 @@@
},
},
- test_notabs => {
+ test_whitespace => {
req => {
+ 'Test::EOL' => '1.0',
'Test::NoTabs' => '0.9',
},
},
- test_eol => {
+ test_strictures => {
req => {
- 'Test::EOL' => '0.6',
+ 'Test::Strict' => '0.20',
},
},
@@@ -191,6 -192,20 +192,20 @@@
req => $json_any,
},
+ test_admin_script => {
+ req => {
+ %$admin_script,
+ 'JSON' => 0,
+ 'JSON::XS' => 0,
+ $^O eq 'MSWin32'
+ # for t/admin/10script.t
+ ? ('Win32::ShellQuote' => 0)
+ # DWIW does not compile (./configure even) on win32
+ : ('JSON::DWIW' => 0 )
+ ,
+ }
+ },
+
test_leaks => {
req => {
'Test::Memory::Cycle' => '0',
@@@ -231,11 -246,9 +246,9 @@@
test_cdbicompat => {
req => {
- 'DBIx::ContextualFetch' => '0',
'Class::DBI::Plugin::DeepAbstractSearch' => '0',
- 'Class::Trigger' => '0',
+ %$datetime_basic,
'Time::Piece::MySQL' => '0',
- 'Clone' => '0',
'Date::Simple' => '3.03',
},
},
@@@ -254,6 -267,7 +267,7 @@@
rdbms_pg => {
req => {
+ # when changing this list make sure to adjust xt/optional_deps.t
%$rdbms_pg,
},
pod => {
@@@ -370,7 -384,7 +384,7 @@@
title => 'Informix support',
desc => 'Modules required to connect to Informix',
},
- },
+ },
rdbms_sqlanywhere => {
req => {
@@@ -380,7 -394,7 +394,7 @@@
title => 'SQLAnywhere support',
desc => 'Modules required to connect to SQLAnywhere',
},
- },
+ },
rdbms_sqlanywhere_odbc => {
req => {
@@@ -390,7 -404,7 +404,7 @@@
title => 'SQLAnywhere support via DBD::ODBC',
desc => 'Modules required to connect to SQLAnywhere via DBD::ODBC',
},
- },
+ },
rdbms_firebird => {
req => {
@@@ -400,7 -414,7 +414,7 @@@
title => 'Firebird support',
desc => 'Modules required to connect to Firebird',
},
- },
+ },
rdbms_firebird_interbase => {
req => {
@@@ -410,7 -424,7 +424,7 @@@
title => 'Firebird support via DBD::InterBase',
desc => 'Modules required to connect to Firebird via DBD::InterBase',
},
- },
+ },
rdbms_firebird_odbc => {
req => {
@@@ -420,7 -434,7 +434,7 @@@
title => 'Firebird support via DBD::ODBC',
desc => 'Modules required to connect to Firebird via DBD::ODBC',
},
- },
+ },
# the order does matter because the rdbms support group might require
# a different version that the test group
@@@ -428,6 -442,7 +442,7 @@@
req => {
$ENV{DBICTEST_PG_DSN}
? (
+ # when changing this list make sure to adjust xt/optional_deps.t
%$rdbms_pg,
($^O ne 'MSWin32' ? ('Sys::SigAction' => '0') : ()),
'DBD::Pg' => '2.009002',
@@@ -594,8 -609,23 +609,23 @@@
},
},
+ dist_dir => {
+ req => {
+ 'ExtUtils::MakeMaker' => '6.64',
+ 'Pod::Inherit' => '0.90',
+ 'Pod::Tree' => '0',
+ }
+ },
+
+ dist_upload => {
+ req => {
+ 'CPAN::Uploader' => '0.103001',
+ },
+ },
+
};
+ our %req_availability_cache;
sub req_list_for {
my ($class, $group) = @_;
@@@ -610,7 -640,16 +640,16 @@@
}
- our %req_availability_cache;
+ sub die_unless_req_ok_for {
+ my ($class, $group) = @_;
+
+ Carp::croak "die_unless_req_ok_for() expects a requirement group name"
+ unless $group;
+
+ $class->_check_deps($group)->{status}
+ or die sprintf( "Required modules missing, unable to continue: %s\n", $class->_check_deps($group)->{missing} );
+ }
+
sub req_ok_for {
my ($class, $group) = @_;
@@@ -686,13 -725,9 +725,9 @@@ sub req_group_list
# This is to be called by the author only (automatically in Makefile.PL)
sub _gen_pod {
- my ($class, $distver) = @_;
+ my ($class, $distver, $pod_dir) = @_;
- my $modfn = __PACKAGE__ . '.pm';
- $modfn =~ s/\:\:/\//g;
-
- my $podfn = __FILE__;
- $podfn =~ s/\.pm$/\.pod/;
+ die "No POD root dir supplied" unless $pod_dir;
$distver ||=
eval { require DBIx::Class; DBIx::Class->VERSION; }
@@@ -705,11 -740,22 +740,22 @@@
"\n\n---------------------------------------------------------------------\n"
;
+ # do not ask for a recent version, use 1.x API calls
+ # this *may* execute on a smoker with old perl or whatnot
+ require File::Path;
+
+ (my $modfn = __PACKAGE__ . '.pm') =~ s|::|/|g;
+
+ (my $podfn = "$pod_dir/$modfn") =~ s/\.pm$/\.pod/;
+ (my $dir = $podfn) =~ s|/[^/]+$||;
+
+ File::Path::mkpath([$dir]);
+
my $sqltver = $class->req_list_for ('deploy')->{'SQL::Translator'}
or die "Hrmm? No sqlt dep?";
my @chunks = (
- <<'EOC',
+ <<"EOC",
#########################################################################
##################### A U T O G E N E R A T E D ########################
#########################################################################
@@@ -785,7 -831,7 +831,7 @@@ EO
'=head2 req_group_list',
'=over',
'=item Arguments: none',
- '=item Returns: \%list_of_requirement_groups',
+ '=item Return Value: \%list_of_requirement_groups',
'=back',
<<'EOD',
This method should be used by DBIx::Class packagers, to get a hashref of all
@@@ -796,7 -842,7 +842,7 @@@ EO
'=head2 req_list_for',
'=over',
'=item Arguments: $group_name',
- '=item Returns: \%list_of_module_version_pairs',
+ '=item Return Value: \%list_of_module_version_pairs',
'=back',
<<'EOD',
This method should be used by DBIx::Class extension authors, to determine the
@@@ -808,7 -854,7 +854,7 @@@ EO
'=head2 req_ok_for',
'=over',
'=item Arguments: $group_name',
- '=item Returns: 1|0',
+ '=item Return Value: 1|0',
'=back',
<<'EOD',
Returns true or false depending on whether all modules required by
@@@ -818,7 -864,7 +864,7 @@@ EO
'=head2 req_missing_for',
'=over',
'=item Arguments: $group_name',
- '=item Returns: $error_message_string',
+ '=item Return Value: $error_message_string',
'=back',
<<"EOD",
Returns a single line string suitable for inclusion in larger error messages.
@@@ -835,13 -881,23 +881,23 @@@ The author is expected to prepend the n
returning the actual error seen by the user.
EOD
+ '=head2 die_unless_req_ok_for',
+ '=over',
+ '=item Arguments: $group_name',
+ '=back',
+ <<'EOD',
+ Checks if L</req_ok_for> passes for the supplied C<$group_name>, and
+ in case of failure throws an exception including the information
+ from L</req_missing_for>.
+ EOD
+
'=head2 req_errorlist_for',
'=over',
'=item Arguments: $group_name',
- '=item Returns: \%list_of_loaderrors_per_module',
+ '=item Return Value: \%list_of_loaderrors_per_module',
'=back',
<<'EOD',
-Returns a hashref containing the actual errors that occured while attempting
+Returns a hashref containing the actual errors that occurred while attempting
to load each module in the requirement group.
EOD
'=head1 AUTHOR',
@@@ -852,6 -908,7 +908,7 @@@
open (my $fh, '>', $podfn) or Carp::croak "Unable to write to $podfn: $!";
print $fh join ("\n\n", @chunks);
+ print $fh "\n";
close ($fh);
}
diff --combined lib/DBIx/Class/Schema.pm
index cb73055,d864853..f0b0fa0
--- a/lib/DBIx/Class/Schema.pm
+++ b/lib/DBIx/Class/Schema.pm
@@@ -3,12 -3,12 +3,12 @@@ package DBIx::Class::Schema
use strict;
use warnings;
- use DBIx::Class::Exception;
use DBIx::Class::Carp;
use Try::Tiny;
- use Scalar::Util 'weaken';
+ use Scalar::Util qw/weaken blessed/;
use Sub::Name 'subname';
use B 'svref_2object';
+ use Devel::GlobalDestruction;
use namespace::clean;
use base qw/DBIx::Class/;
@@@ -167,12 -167,9 +167,9 @@@ sub _findallmod
my $ns = shift || ref $proto || $proto;
require Module::Find;
- my @mods = Module::Find::findallmod($ns);
- # try to untaint module names. mods where this fails
- # are left alone so we don't have to change the old behavior
- no locale; # localized \w doesn't untaint expression
- return map { $_ =~ m/^( (?:\w+::)* \w+ )$/x ? $1 : $_ } @mods;
+ # untaint result
+ return map { $_ =~ /(.+)/ } Module::Find::findallmod($ns);
}
# returns a hash of $shortname => $fullname for every package
@@@ -408,7 -405,7 +405,7 @@@ sub load_classes
=item Arguments: $storage_type|{$storage_type, \%args}
- =item Return value: $storage_type|{$storage_type, \%args}
+ =item Return Value: $storage_type|{$storage_type, \%args}
=item Default value: DBIx::Class::Storage::DBI
@@@ -434,7 -431,7 +431,7 @@@ L<DBIx::Class::Storage::DBI::Replicated
=item Arguments: $code_reference
- =item Return value: $code_reference
+ =item Return Value: $code_reference
=item Default value: None
@@@ -532,9 -529,9 +529,9 @@@ sub connect { shift->clone->connection(
=over 4
- =item Arguments: $source_name
+ =item Arguments: L<$source_name|DBIx::Class::ResultSource/source_name>
- =item Return Value: $resultset
+ =item Return Value: L<$resultset|DBIx::Class::ResultSet>
=back
@@@ -546,17 -543,17 +543,17 @@@ name
=cut
sub resultset {
- my ($self, $moniker) = @_;
+ my ($self, $source_name) = @_;
$self->throw_exception('resultset() expects a source name')
- unless defined $moniker;
- return $self->source($moniker)->resultset;
+ unless defined $source_name;
+ return $self->source($source_name)->resultset;
}
=head2 sources
=over 4
- =item Return Value: @source_names
+ =item Return Value: L<@source_names|DBIx::Class::ResultSource/source_name>
=back
@@@ -572,9 -569,9 +569,9 @@@ sub sources { return keys %{shift->sour
=over 4
- =item Arguments: $source_name
+ =item Arguments: L<$source_name|DBIx::Class::ResultSource/source_name>
- =item Return Value: $result_source
+ =item Return Value: L<$result_source|DBIx::Class::ResultSource>
=back
@@@ -591,14 -588,14 +588,14 @@@ sub source
$self->throw_exception("source() expects a source name")
unless @_;
- my $moniker = shift;
+ my $source_name = shift;
my $sreg = $self->source_registrations;
- return $sreg->{$moniker} if exists $sreg->{$moniker};
+ return $sreg->{$source_name} if exists $sreg->{$source_name};
# if we got here, they probably passed a full class name
- my $mapped = $self->class_mappings->{$moniker};
- $self->throw_exception("Can't find source for ${moniker}")
+ my $mapped = $self->class_mappings->{$source_name};
+ $self->throw_exception("Can't find source for ${source_name}")
unless $mapped && exists $sreg->{$mapped};
return $sreg->{$mapped};
}
@@@ -607,7 -604,7 +604,7 @@@
=over 4
- =item Arguments: $source_name
+ =item Arguments: L<$source_name|DBIx::Class::ResultSource/source_name>
=item Return Value: $classname
@@@ -620,8 -617,7 +617,7 @@@ Retrieves the Result class name for th
=cut
sub class {
- my ($self, $moniker) = @_;
- return $self->source($moniker)->result_class;
+ return shift->source(shift)->result_class;
}
=head2 txn_do
@@@ -740,59 -736,42 +736,42 @@@ found in L<DBIx::Class::Storage::DBI>
=over 4
- =item Arguments: $source_name, \@data;
+ =item Arguments: L<$source_name|DBIx::Class::ResultSource/source_name>, [ \@column_list, \@row_values+ ] | [ \%col_data+ ]
- =item Return value: \@$objects | nothing
+ =item Return Value: L<\@result_objects|DBIx::Class::Manual::ResultClass> (scalar context) | L<@result_objects|DBIx::Class::Manual::ResultClass> (list context)
=back
- Pass this method a resultsource name, and an arrayref of
- arrayrefs. The arrayrefs should contain a list of column names,
- followed by one or many sets of matching data for the given columns.
-
- In void context, C<insert_bulk> in L<DBIx::Class::Storage::DBI> is used
- to insert the data, as this is a fast method. However, insert_bulk currently
- assumes that your datasets all contain the same type of values, using scalar
- references in a column in one row, and not in another will probably not work.
+ A convenience shortcut to L<DBIx::Class::ResultSet/populate>. Equivalent to:
- Otherwise, each set of data is inserted into the database using
- L<DBIx::Class::ResultSet/create>, and a arrayref of the resulting row
- objects is returned.
+ $schema->resultset($source_name)->populate([...]);
- e.g.
+ =over 4
- $schema->populate('Artist', [
- [ qw/artistid name/ ],
- [ 1, 'Popular Band' ],
- [ 2, 'Indie Band' ],
- ...
- ]);
+ =item NOTE
- Since wantarray context is basically the same as looping over $rs->create(...)
- you won't see any performance benefits and in this case the method is more for
- convenience. Void context sends the column information directly to storage
- using <DBI>s bulk insert method. So the performance will be much better for
- storages that support this method.
+ The context of this method call has an important effect on what is
+ submitted to storage. In void context data is fed directly to fastpath
+ insertion routines provided by the underlying storage (most often
+ L<DBI/execute_for_fetch>), bypassing the L<new|DBIx::Class::Row/new> and
+ L<insert|DBIx::Class::Row/insert> calls on the
+ L<Result|DBIx::Class::Manual::ResultClass> class, including any
+ augmentation of these methods provided by components. For example if you
+ are using something like L<DBIx::Class::UUIDColumns> to create primary
+ keys for you, you will find that your PKs are empty. In this case you
+ will have to explicitly force scalar or list context in order to create
+ those values.
- Because of this difference in the way void context inserts rows into your
- database you need to note how this will effect any loaded components that
- override or augment insert. For example if you are using a component such
- as L<DBIx::Class::UUIDColumns> to populate your primary keys you MUST use
- wantarray context if you want the PKs automatically created.
+ =back
=cut
sub populate {
my ($self, $name, $data) = @_;
- if(my $rs = $self->resultset($name)) {
- if(defined wantarray) {
- return $rs->populate($data);
- } else {
- $rs->populate($data);
- }
- } else {
- $self->throw_exception("$name is not a resultset");
- }
+ my $rs = $self->resultset($name)
+ or $self->throw_exception("'$name' is not a resultset");
+
+ return $rs->populate($data);
}
=head2 connection
@@@ -887,16 -866,16 +866,16 @@@ will produce the outpu
# my ($self, $target, $base) = @_;
# my $schema = $self->clone;
- # foreach my $moniker ($schema->sources) {
- # my $source = $schema->source($moniker);
- # my $target_class = "${target}::${moniker}";
+ # foreach my $source_name ($schema->sources) {
+ # my $source = $schema->source($source_name);
+ # my $target_class = "${target}::${source_name}";
# $self->inject_base(
# $target_class => $source->result_class, ($base ? $base : ())
# );
# $source->result_class($target_class);
# $target_class->result_source_instance($source)
# if $target_class->can('result_source_instance');
- # $schema->register_source($moniker, $source);
+ # $schema->register_source($source_name, $source);
# }
# return $schema;
# }
@@@ -918,14 -897,14 +897,14 @@@ sub compose_namespace
use warnings qw/redefine/;
no strict qw/refs/;
- foreach my $moniker ($self->sources) {
- my $orig_source = $self->source($moniker);
+ foreach my $source_name ($self->sources) {
+ my $orig_source = $self->source($source_name);
- my $target_class = "${target}::${moniker}";
+ my $target_class = "${target}::${source_name}";
$self->inject_base($target_class, $orig_source->result_class, ($base || ()) );
# register_source examines result_class, and then returns us a clone
- my $new_source = $schema->register_source($moniker, bless
+ my $new_source = $schema->register_source($source_name, bless
{ %$orig_source, result_class => $target_class },
ref $orig_source,
);
@@@ -1021,7 -1000,7 +1000,7 @@@ sub svp_rollback
Clones the schema and its associated result_source objects and returns the
copy. The resulting copy will have the same attributes as the source schema,
-except for those attributes explicitly overriden by the provided C<%attrs>.
+except for those attributes explicitly overridden by the provided C<%attrs>.
=cut
@@@ -1034,18 -1013,33 +1013,33 @@@ sub clone
};
bless $clone, (ref $self || $self);
- $clone->class_mappings({ %{$clone->class_mappings} });
- $clone->source_registrations({ %{$clone->source_registrations} });
- foreach my $moniker ($self->sources) {
- my $source = $self->source($moniker);
+ $clone->$_(undef) for qw/class_mappings source_registrations storage/;
+
+ $clone->_copy_state_from($self);
+
+ return $clone;
+ }
+
+ # Needed in Schema::Loader - if you refactor, please make a compatibility shim
+ # -- Caelum
+ sub _copy_state_from {
+ my ($self, $from) = @_;
+
+ $self->class_mappings({ %{$from->class_mappings} });
+ $self->source_registrations({ %{$from->source_registrations} });
+
+ foreach my $source_name ($from->sources) {
+ my $source = $from->source($source_name);
my $new = $source->new($source);
# we use extra here as we want to leave the class_mappings as they are
# but overwrite the source_registrations entry with the new source
- $clone->register_extra_source($moniker => $new);
+ $self->register_extra_source($source_name => $new);
}
- $clone->storage->set_schema($clone) if $clone->storage;
- return $clone;
+ if ($from->storage) {
+ $self->storage($from->storage);
+ $self->storage->set_schema($self);
+ }
}
=head2 throw_exception
@@@ -1063,7 -1057,6 +1057,6 @@@ default behavior will provide a detaile
=cut
- my $false_exception_action_warned;
sub throw_exception {
my $self = shift;
@@@ -1076,13 -1069,12 +1069,12 @@@
." (original error: $_[0])"
);
}
- elsif(! $false_exception_action_warned++) {
- carp (
- "The exception_action handler installed on $self returned false instead"
- .' of throwing an exception. This behavior has been deprecated, adjust your'
- .' handler to always rethrow the supplied error.'
- );
- }
+
+ carp_unique (
+ "The exception_action handler installed on $self returned false instead"
+ .' of throwing an exception. This behavior has been deprecated, adjust your'
+ .' handler to always rethrow the supplied error.'
+ );
}
DBIx::Class::Exception->throw($_[0], $self->stacktrace);
@@@ -1101,8 -1093,7 +1093,7 @@@ Attempts to deploy the schema to the cu
See L<SQL::Translator/METHODS> for a list of values for C<\%sqlt_args>.
The most common value for this would be C<< { add_drop_table => 1 } >>
to have the SQL produced include a C<DROP TABLE> statement for each table
- created. For quoting purposes supply C<quote_table_names> and
- C<quote_field_names>.
+ created. For quoting purposes supply C<quote_identifiers>.
Additionally, the DBIx::Class parser accepts a C<sources> parameter as a hash
ref or an array ref, containing a list of source to deploy. If present, then
@@@ -1124,7 -1115,7 +1115,7 @@@ sub deploy
=item Arguments: See L<DBIx::Class::Storage::DBI/deployment_statements>
- =item Return value: $listofstatements
+ =item Return Value: $listofstatements
=back
@@@ -1173,7 -1164,7 +1164,7 @@@ sub create_ddl_dir
=item Arguments: $database-type, $version, $directory, $preversion
- =item Return value: $normalised_filename
+ =item Return Value: $normalised_filename
=back
@@@ -1206,12 -1197,12 +1197,12 @@@ sub ddl_filename
require File::Spec;
- my $filename = ref($self);
- $filename =~ s/::/-/g;
- $filename = File::Spec->catfile($dir, "$filename-$version-$type.sql");
- $filename =~ s/$version/$preversion-$version/ if($preversion);
+ $version = "$preversion-$version" if $preversion;
+
+ my $class = blessed($self) || $self;
+ $class =~ s/::/-/g;
- return $filename;
+ return File::Spec->catfile($dir, "$class-$version-$type.sql");
}
=head2 thaw
@@@ -1292,7 -1283,7 +1283,7 @@@ sub schema_version
=over 4
- =item Arguments: $moniker, $component_class
+ =item Arguments: $source_name, $component_class
=back
@@@ -1305,27 -1296,27 +1296,27 @@@ file). You may also need it to registe
Registers a class which isa DBIx::Class::ResultSourceProxy. Equivalent to
calling:
- $schema->register_source($moniker, $component_class->result_source_instance);
+ $schema->register_source($source_name, $component_class->result_source_instance);
=cut
sub register_class {
- my ($self, $moniker, $to_register) = @_;
- $self->register_source($moniker => $to_register->result_source_instance);
+ my ($self, $source_name, $to_register) = @_;
+ $self->register_source($source_name => $to_register->result_source_instance);
}
=head2 register_source
=over 4
- =item Arguments: $moniker, $result_source
+ =item Arguments: $source_name, L<$result_source|DBIx::Class::ResultSource>
=back
This method is called by L</register_class>.
Registers the L<DBIx::Class::ResultSource> in the schema with the given
- moniker.
+ source name.
=cut
@@@ -1335,11 -1326,11 +1326,11 @@@ sub register_source { shift->_register_
=over 4
- =item Arguments: $moniker
+ =item Arguments: $source_name
=back
- Removes the L<DBIx::Class::ResultSource> from the schema for the given moniker.
+ Removes the L<DBIx::Class::ResultSource> from the schema for the given source name.
=cut
@@@ -1349,7 -1340,7 +1340,7 @@@ sub unregister_source { shift->_unregis
=over 4
- =item Arguments: $moniker, $result_source
+ =item Arguments: $source_name, L<$result_source|DBIx::Class::ResultSource>
=back
@@@ -1361,15 -1352,15 +1352,15 @@@ has a source and you want to register a
sub register_extra_source { shift->_register_source(@_, { extra => 1 }) }
sub _register_source {
- my ($self, $moniker, $source, $params) = @_;
+ my ($self, $source_name, $source, $params) = @_;
- $source = $source->new({ %$source, source_name => $moniker });
+ $source = $source->new({ %$source, source_name => $source_name });
$source->schema($self);
weaken $source->{schema} if ref($self);
my %reg = %{$self->source_registrations};
- $reg{$moniker} = $source;
+ $reg{$source_name} = $source;
$self->source_registrations(\%reg);
return $source if $params->{extra};
@@@ -1380,7 -1371,7 +1371,7 @@@
if (
exists $map{$rs_class}
and
- $map{$rs_class} ne $moniker
+ $map{$rs_class} ne $source_name
and
$rsrc ne $_[2] # orig_source
) {
@@@ -1391,55 -1382,48 +1382,48 @@@
;
}
- $map{$rs_class} = $moniker;
+ $map{$rs_class} = $source_name;
$self->class_mappings(\%map);
}
return $source;
}
- {
- my $global_phase_destroy;
-
- # SpeedyCGI runs END blocks every cycle but keeps object instances
- # hence we have to disable the globaldestroy hatch, and rely on the
- # eval trap below (which appears to work, but is risky done so late)
- END { $global_phase_destroy = 1 unless $CGI::SpeedyCGI::i_am_speedy }
-
- sub DESTROY {
- return if $global_phase_destroy;
-
- my $self = shift;
- my $srcs = $self->source_registrations;
-
- for my $moniker (keys %$srcs) {
- # find first source that is not about to be GCed (someone other than $self
- # holds a reference to it) and reattach to it, weakening our own link
- #
- # during global destruction (if we have not yet bailed out) this will throw
- # which will serve as a signal to not try doing anything else
- if (ref $srcs->{$moniker} and svref_2object($srcs->{$moniker})->REFCNT > 1) {
- local $@;
- eval {
- $srcs->{$moniker}->schema($self);
- 1;
- } or do {
- $global_phase_destroy = 1;
- last;
- };
-
- weaken $srcs->{$moniker};
- last;
- }
+ my $global_phase_destroy;
+ sub DESTROY {
+ return if $global_phase_destroy ||= in_global_destruction;
+
+ my $self = shift;
+ my $srcs = $self->source_registrations;
+
+ for my $source_name (keys %$srcs) {
+ # find first source that is not about to be GCed (someone other than $self
+ # holds a reference to it) and reattach to it, weakening our own link
+ #
+ # during global destruction (if we have not yet bailed out) this should throw
+ # which will serve as a signal to not try doing anything else
+ # however beware - on older perls the exception seems randomly untrappable
+ # due to some weird race condition during thread joining :(((
+ if (ref $srcs->{$source_name} and svref_2object($srcs->{$source_name})->REFCNT > 1) {
+ local $@;
+ eval {
+ $srcs->{$source_name}->schema($self);
+ weaken $srcs->{$source_name};
+ 1;
+ } or do {
+ $global_phase_destroy = 1;
+ };
+
+ last;
}
}
}
sub _unregister_source {
- my ($self, $moniker) = @_;
+ my ($self, $source_name) = @_;
my %reg = %{$self->source_registrations};
- my $source = delete $reg{$moniker};
+ my $source = delete $reg{$source_name};
$self->source_registrations(\%reg);
if ($source->result_class) {
my %map = %{$self->class_mappings};
@@@ -1500,8 -1484,8 +1484,8 @@@ sub compose_connection
if ($self eq $target) {
# Pathological case, largely caused by the docs on early C::M::DBIC::Plain
- foreach my $moniker ($self->sources) {
- my $source = $self->source($moniker);
+ foreach my $source_name ($self->sources) {
+ my $source = $self->source($source_name);
my $class = $source->result_class;
$self->inject_base($class, $base);
$class->mk_classdata(resultset_instance => $source->resultset);
@@@ -1519,10 -1503,10 +1503,10 @@@
}
$schema->connection(@info);
- foreach my $moniker ($schema->sources) {
- my $source = $schema->source($moniker);
+ foreach my $source_name ($schema->sources) {
+ my $source = $schema->source($source_name);
my $class = $source->result_class;
- #warn "$moniker $class $source ".$source->storage;
+ #warn "$source_name $class $source ".$source->storage;
$class->mk_classdata(result_source_instance => $source);
$class->mk_classdata(resultset_instance => $source->resultset);
$class->mk_classdata(class_resolver => $schema);
@@@ -1532,9 -1516,9 +1516,9 @@@
1;
- =head1 AUTHORS
+ =head1 AUTHOR AND CONTRIBUTORS
- Matt S. Trout <mst at shadowcatsystems.co.uk>
+ See L<AUTHOR|DBIx::Class/AUTHOR> and L<CONTRIBUTORS|DBIx::Class/CONTRIBUTORS> in DBIx::Class
=head1 LICENSE
--
Debian packaging of libdbix-class-perl
More information about the Pkg-perl-cvs-commits
mailing list