Skip to content

Commit

Permalink
Merge branch 'master' into topic/constructor_rewrite
Browse files Browse the repository at this point in the history
Add some extra code to enforce the assumption that any bind type constant
is accessible in _dbi_attrs_for_bind, or in other words that all necessary
DBDs are already loaded (concept originally introduced in ad7c50f)

Without this the combination of 9930caa (do not recalculate bind attrs
on dbh_do retry) and a2f2285 (do not wrap iterators in dbh_do) can result
in _dbi_attrs_for_bind being called before DBI/DBD::* has been loaded at all
  • Loading branch information
ribasushi committed Apr 4, 2013
2 parents 894108b + 5a1dea8 commit 524343a
Show file tree
Hide file tree
Showing 42 changed files with 640 additions and 329 deletions.
22 changes: 22 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,15 @@ matrix:
- CLEANTEST=false
- BREWOPTS="-Duseithreads"
- BREWVER=5.8.5
- DBIC_TRACE_PROFILE=console

# minimum supported without threads
- perl: 5.8.3_nt
env:
- CLEANTEST=false
- BREWOPTS=""
- BREWVER=5.8.3
- DBIC_TRACE_PROFILE=console_monochrome

# check CLEANTEST of minimum supported
- perl: 5.8.3_nt_mb
Expand All @@ -111,6 +113,26 @@ matrix:
- BREWOPTS="-Duseithreads -Dusemorebits"
- BREWVER=5.8.8

# some permutations of tracing and envvar poisoning
- perl: 5.16
env:
- CLEANTEST=false
- POISON_ENV=true

- perl: 5.16
env:
- CLEANTEST=true
- POISON_ENV=true
- DBIC_TRACE=1
- DBIC_TRACE_PROFILE=console

- perl: 5.16
env:
- CLEANTEST=false
- POISON_ENV=true
- DBIC_TRACE=1
- DBIC_TRACE_PROFILE=console_monochrome

# sourcing the files is *EXTREMELY* important - otherwise
# no envvars will survive

Expand Down
14 changes: 14 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
Revision history for DBIx::Class

0.08210 2013-04-04 15:30 (UTC)
* New Features / Changes
- Officially deprecate the 'cols' and 'include_columns' resultset
attributes
- Remove ::Storage::DBI::sth() deprecated in 0.08191

* Fixes
- Work around a *critical* bug with potential for data loss in
DBD::SQLite - RT#79576
- Audit and correct potential bugs associated with braindead reuse
of $1 on unsuccessful matches
- Fix incorrect warning/exception originator reported by carp*() and
throw_exception()

0.08242-TRIAL (EXPERIMENTAL BETA RELEASE) 2013-03-10 14:44 (UTC)
* New Features / Changes
- Prefetch with limit on right-side ordered resultsets now works
Expand Down
91 changes: 51 additions & 40 deletions lib/DBIx/Class.pm
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ sub _attr_cache {

1;

__END__
=encoding UTF-8
=head1 NAME
DBIx::Class - Extensible and flexible object <-> relational mapper.
Expand Down Expand Up @@ -131,41 +135,11 @@ list below is sorted by "fastest response time":
=back
=head1 HOW TO CONTRIBUTE
Contributions are always welcome, in all usable forms (we especially
welcome documentation improvements). The delivery methods include git-
or unified-diff formatted patches, GitHub pull requests, or plain bug
reports either via RT or the Mailing list. Contributors are generally
granted full access to the official repository after their first patch
passes successful review.
=for comment
FIXME: Getty, frew and jnap need to get off their asses and finish the contrib section so we can link it here ;)
This project is maintained in a git repository. The code and related tools are
accessible at the following locations:
=over
=item * Official repo: L<git://git.shadowcat.co.uk/dbsrgits/DBIx-Class.git>
=item * Official gitweb: L<http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=dbsrgits/DBIx-Class.git>
=item * GitHub mirror: L<https://github.com/dbsrgits/DBIx-Class>
=item * Authorized committers: L<ssh://dbsrgits@git.shadowcat.co.uk/DBIx-Class.git>
=item * Travis-CI log: L<https://travis-ci.org/dbsrgits/dbix-class/builds>
=for html
<br>&#x21AA; Stable branch CI status: <img src="https://secure.travis-ci.org/dbsrgits/dbix-class.png?branch=master"></img>
=back
=head1 SYNOPSIS
Create a schema class called MyApp/Schema.pm:
=head2 Schema classes preparation
Create a schema class called F<MyApp/Schema.pm>:
package MyApp::Schema;
use base qw/DBIx::Class::Schema/;
Expand All @@ -175,7 +149,7 @@ Create a schema class called MyApp/Schema.pm:
1;
Create a result class to represent artists, who have many CDs, in
MyApp/Schema/Result/Artist.pm:
F<MyApp/Schema/Result/Artist.pm>:
See L<DBIx::Class::ResultSource> for docs on defining result classes.
Expand All @@ -190,7 +164,7 @@ See L<DBIx::Class::ResultSource> for docs on defining result classes.
1;
A result class to represent a CD, which belongs to an artist, in
MyApp/Schema/Result/CD.pm:
F<MyApp/Schema/Result/CD.pm>:
package MyApp::Schema::Result::CD;
use base qw/DBIx::Class::Core/;
Expand All @@ -203,6 +177,8 @@ MyApp/Schema/Result/CD.pm:
1;
=head2 API usage
Then you can use these classes in your application's code:
# Connect to your database.
Expand Down Expand Up @@ -271,7 +247,8 @@ that allows abstract encapsulation of database operations. It aims to make
representing queries in your code as perl-ish as possible while still
providing access to as many of the capabilities of the database as possible,
including retrieving related records from multiple tables in a single query,
JOIN, LEFT JOIN, COUNT, DISTINCT, GROUP BY, ORDER BY and HAVING support.
C<JOIN>, C<LEFT JOIN>, C<COUNT>, C<DISTINCT>, C<GROUP BY>, C<ORDER BY> and
C<HAVING> support.
DBIx::Class can handle multi-column primary and foreign keys, complex
queries and database-level paging, and does its best to only query the
Expand All @@ -284,8 +261,8 @@ and thread-safe out of the box (although
L<your DBD may not be|DBI/Threads and Thread Safety>).
This project is still under rapid development, so large new features may be
marked EXPERIMENTAL - such APIs are still usable but may have edge bugs.
Failing test cases are *always* welcome and point releases are put out rapidly
marked B<experimental> - such APIs are still usable but may have edge bugs.
Failing test cases are I<always> welcome and point releases are put out rapidly
as bugs are found and fixed.
We do our best to maintain full backwards compatibility for published
Expand All @@ -297,6 +274,38 @@ The test suite is quite substantial, and several developer releases
are generally made to CPAN before the branch for the next release is
merged back to trunk for a major release.
=head1 HOW TO CONTRIBUTE
Contributions are always welcome, in all usable forms (we especially
welcome documentation improvements). The delivery methods include git-
or unified-diff formatted patches, GitHub pull requests, or plain bug
reports either via RT or the Mailing list. Contributors are generally
granted full access to the official repository after their first patch
passes successful review.
=for comment
FIXME: Getty, frew and jnap need to get off their asses and finish the contrib section so we can link it here ;)
This project is maintained in a git repository. The code and related tools are
accessible at the following locations:
=over
=item * Official repo: L<git://git.shadowcat.co.uk/dbsrgits/DBIx-Class.git>
=item * Official gitweb: L<http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=dbsrgits/DBIx-Class.git>
=item * GitHub mirror: L<https://github.com/dbsrgits/DBIx-Class>
=item * Authorized committers: L<ssh://dbsrgits@git.shadowcat.co.uk/DBIx-Class.git>
=item * Travis-CI log: L<https://travis-ci.org/dbsrgits/dbix-class/builds>
=for html
&#x21AA; Stable branch CI status: <img src="https://secure.travis-ci.org/dbsrgits/dbix-class.png?branch=master"></img>
=back
=head1 AUTHOR
mst: Matt S. Trout <mst@shadowcatsystems.co.uk>
Expand Down Expand Up @@ -362,8 +371,12 @@ clkao: CL Kao
da5id: David Jack Olrik <djo@cpan.org>
dariusj: Darius Jokilehto <dariusjokilehto@yahoo.co.uk>
davewood: David Schmidt <davewood@gmx.at>
daxim: Lars Dɪᴇᴄᴋᴏᴡ 迪拉斯 <daxim@cpan.org>
debolaz: Anders Nor Berle <berle@cpan.org>
dew: Dan Thomas <dan@godders.org>
Expand Down Expand Up @@ -563,5 +576,3 @@ as listed above.
This library is free software and may be distributed under the same terms
as perl itself.
=cut
2 changes: 1 addition & 1 deletion lib/DBIx/Class/CDBICompat/Constraints.pm
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ sub constrain_column {
} elsif (ref $how eq "Regexp") {
$class->add_constraint(regexp => $col => sub { shift =~ $how });
} else {
$how =~ m/([^:]+)$/;
$how =~ m/([^:]+)$/; # match is safe - we throw above on empty $how
my $try_method = sprintf '_constrain_by_%s', lc $1; # $how->moniker;
if (my $dispatch = $class->can($try_method)) {
$class->$dispatch($col => ($how, @_));
Expand Down
4 changes: 3 additions & 1 deletion lib/DBIx/Class/CDBICompat/ImaDBI.pm
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ sub set_sql {
sub {
my $sql = $sql;
my $class = shift;
return $class->storage->_sth($class->transform_sql($sql, @_));
return $class->storage->dbh_do(
_prepare_sth => $class->transform_sql($sql, @_)
);
};
if ($sql =~ /select/i) {
my $search_name = "search_${name}";
Expand Down
28 changes: 22 additions & 6 deletions lib/DBIx/Class/Carp.pm
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ BEGIN {
use Carp ();
use namespace::clean ();

$Carp::Internal{ (__PACKAGE__) }++;

sub __find_caller {
my ($skip_pattern, $class) = @_;

Expand All @@ -28,8 +30,21 @@ sub __find_caller {
if $skip_class_data;

my $fr_num = 1; # skip us and the calling carp*
my @f;

my (@f, $origin);
while (@f = caller($fr_num++)) {

next if
( $f[3] eq '(eval)' or $f[3] =~ /::__ANON__$/ );

$origin ||= (
$f[3] =~ /^ (.+) :: ([^\:]+) $/x
and
! $Carp::Internal{$1}
and
$2 !~ /^(?: throw_exception | carp | carp_unique | carp_once )$/x
) ? $f[3] : undef;

if (
$f[0]->can('_skip_namespace_frames')
and
Expand All @@ -41,14 +56,15 @@ sub __find_caller {
last if $f[0] !~ $skip_pattern;
}

my ($ln, $calling) = @f # if empty - nothing matched - full stack
? ( "at $f[1] line $f[2]", $f[3] )
: ( Carp::longmess(), '{UNKNOWN}' )
my $site = @f # if empty - nothing matched - full stack
? "at $f[1] line $f[2]"
: Carp::longmess()
;
$origin ||= '{UNKNOWN}';

return (
$ln,
$calling =~ /::/ ? "$calling(): " : "$calling: ", # cargo-cult from Carp::Clan
$site,
$origin =~ /::/ ? "$origin(): " : "$origin: ", # cargo-cult from Carp::Clan
);
};

Expand Down
1 change: 1 addition & 0 deletions lib/DBIx/Class/Exception.pm
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use strict;
use warnings;

use DBIx::Class::Carp ();
$Carp::Internal{ (__PACKAGE__) }++;

use overload
'""' => sub { shift->{msg} },
Expand Down
2 changes: 1 addition & 1 deletion lib/DBIx/Class/Relationship/HasMany.pm
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ sub has_many {
$f_key = $cond;
$guess = "caller specified foreign key '$f_key'";
} else {
$class =~ /([^\:]+)$/;
$class =~ /([^\:]+)$/; # match is safe - $class can't be ''
$f_key = lc $1; # go ahead and guess; best we can do
$guess = "using our class name '$class' as foreign key";
}
Expand Down
32 changes: 15 additions & 17 deletions lib/DBIx/Class/ResultSet.pm
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,7 @@ sub search_rs {

# older deprecated name, use only if {columns} is not there
if (my $c = delete $new_attrs->{cols}) {
carp_unique( "Resultset attribute 'cols' is deprecated, use 'columns' instead" );
if ($new_attrs->{columns}) {
carp "Resultset specifies both the 'columns' and the legacy 'cols' attributes - ignoring 'cols'";
}
Expand Down Expand Up @@ -489,8 +490,12 @@ sub _normalize_selection {
my ($self, $attrs) = @_;

# legacy syntax
$attrs->{'+columns'} = $self->_merge_attr($attrs->{'+columns'}, delete $attrs->{include_columns})
if exists $attrs->{include_columns};
if ( exists $attrs->{include_columns} ) {
carp_unique( "Resultset attribute 'include_columns' is deprecated, use '+columns' instead" );
$attrs->{'+columns'} = $self->_merge_attr(
$attrs->{'+columns'}, delete $attrs->{include_columns}
);
}

# columns are always placed first, however

Expand Down Expand Up @@ -2606,16 +2611,9 @@ sub as_query {

my $attrs = { %{ $self->_resolved_attrs } };

# For future use:
#
# in list ctx:
# my ($sql, \@bind, \%dbi_bind_attrs) = _select_args_to_query (...)
# $sql also has no wrapping parenthesis in list ctx
#
my $sqlbind = $self->result_source->storage
->_select_args_to_query ($attrs->{from}, $attrs->{select}, $attrs->{where}, $attrs);

return $sqlbind;
$self->result_source->storage->_select_args_to_query (
$attrs->{from}, $attrs->{select}, $attrs->{where}, $attrs
);
}

=head2 find_or_new
Expand Down Expand Up @@ -3919,7 +3917,7 @@ case the key is the C<as> value, and the value is used as the C<select>
expression). Adds C<me.> onto the start of any column without a C<.> in
it and sets C<select> from that, then auto-populates C<as> from
C<select> as normal. (You may also use the C<cols> attribute, as in
earlier versions of DBIC.)
earlier versions of DBIC, but this is deprecated.)
Essentially C<columns> does the same as L</select> and L</as>.
Expand All @@ -3938,10 +3936,10 @@ is the same as
=back
Indicates additional columns to be selected from storage. Works the same
as L</columns> but adds columns to the selection. (You may also use the
C<include_columns> attribute, as in earlier versions of DBIC). For
example:-
Indicates additional columns to be selected from storage. Works the same as
L</columns> but adds columns to the selection. (You may also use the
C<include_columns> attribute, as in earlier versions of DBIC, but this is
deprecated). For example:-
$schema->resultset('CD')->search(undef, {
'+columns' => ['artist.name'],
Expand Down
Loading

0 comments on commit 524343a

Please sign in to comment.