[Bast-commits] r6159 - in
DBIx-Class/0.08/branches/fix-update-and-delete-as_query:
lib/DBIx/Class lib/DBIx/Class/Storage/DBI t/resultset
ribasushi at dev.catalyst.perl.org
ribasushi at dev.catalyst.perl.org
Thu May 7 09:58:14 GMT 2009
Author: ribasushi
Date: 2009-05-07 09:58:14 +0000 (Thu, 07 May 2009)
New Revision: 6159
Modified:
DBIx-Class/0.08/branches/fix-update-and-delete-as_query/lib/DBIx/Class/ResultSet.pm
DBIx-Class/0.08/branches/fix-update-and-delete-as_query/lib/DBIx/Class/ResultSetColumn.pm
DBIx-Class/0.08/branches/fix-update-and-delete-as_query/lib/DBIx/Class/Storage/DBI/Cursor.pm
DBIx-Class/0.08/branches/fix-update-and-delete-as_query/t/resultset/as_query.t
Log:
Back out skip_parens support in as_query
Modified: DBIx-Class/0.08/branches/fix-update-and-delete-as_query/lib/DBIx/Class/ResultSet.pm
===================================================================
--- DBIx-Class/0.08/branches/fix-update-and-delete-as_query/lib/DBIx/Class/ResultSet.pm 2009-05-07 09:55:12 UTC (rev 6158)
+++ DBIx-Class/0.08/branches/fix-update-and-delete-as_query/lib/DBIx/Class/ResultSet.pm 2009-05-07 09:58:14 UTC (rev 6159)
@@ -1333,7 +1333,7 @@
return $cond unless ref $full_cond;
foreach my $pk ($self->result_source->primary_columns) {
- $cond->{$pk} = { IN => $self->get_column($pk)->as_query({ skip_parens => 1 }) };
+ $cond->{$pk} = { -in => $self->get_column($pk)->as_query };
}
return $cond;
@@ -1810,7 +1810,7 @@
=over 4
-=item Arguments: \%opts
+=item Arguments: none
=item Return Value: \[ $sql, @bind ]
@@ -1822,14 +1822,6 @@
B<NOTE>: This feature is still experimental.
-The query returned will be surrounded by parentheses, e.g:
-
- ( SELECT cdid FROM cd WHERE title LIKE '%Hits%' )
-
-This behaviour can be changed by passing special options:
-
- $rs->get_column('cdid')->as_query({ skip_parens => 1 });
-
=cut
sub as_query { return shift->cursor->as_query(@_) }
Modified: DBIx-Class/0.08/branches/fix-update-and-delete-as_query/lib/DBIx/Class/ResultSetColumn.pm
===================================================================
--- DBIx-Class/0.08/branches/fix-update-and-delete-as_query/lib/DBIx/Class/ResultSetColumn.pm 2009-05-07 09:55:12 UTC (rev 6158)
+++ DBIx-Class/0.08/branches/fix-update-and-delete-as_query/lib/DBIx/Class/ResultSetColumn.pm 2009-05-07 09:58:14 UTC (rev 6159)
@@ -58,7 +58,7 @@
=over 4
-=item Arguments: See L<DBIx::Class::ResultSet/as_query>
+=item Arguments: none
=item Return Value: \[ $sql, @bind ]
Modified: DBIx-Class/0.08/branches/fix-update-and-delete-as_query/lib/DBIx/Class/Storage/DBI/Cursor.pm
===================================================================
--- DBIx-Class/0.08/branches/fix-update-and-delete-as_query/lib/DBIx/Class/Storage/DBI/Cursor.pm 2009-05-07 09:55:12 UTC (rev 6158)
+++ DBIx-Class/0.08/branches/fix-update-and-delete-as_query/lib/DBIx/Class/Storage/DBI/Cursor.pm 2009-05-07 09:58:14 UTC (rev 6159)
@@ -53,7 +53,7 @@
=over 4
-=item Arguments: See L<DBIx::Class::ResultSet/as_query>
+=item Arguments: none
=item Return Value: \[ $sql, @bind ]
@@ -64,21 +64,15 @@
=cut
sub as_query {
- my ( $self, $opts ) = @_;
+ my $self = shift;
- $self->throw_exception( "as_query needs a hashref" )
- if defined $opts and ref $opts ne 'HASH';
-
- $opts->{skip_parens} ||= 0;
-
my $storage = $self->{storage};
my $sql_maker = $storage->sql_maker;
local $sql_maker->{for};
my @args = $storage->_select_args(@{$self->{args}});
my ($sql, $bind) = $storage->_prep_for_execute(@args[0 .. 2], [@args[4 .. $#args]]);
- $sql = "($sql)" unless $opts->{skip_parens};
- return \[ $sql, @$bind ];
+ return \[ "($sql)", @$bind ];
}
=head2 next
Modified: DBIx-Class/0.08/branches/fix-update-and-delete-as_query/t/resultset/as_query.t
===================================================================
--- DBIx-Class/0.08/branches/fix-update-and-delete-as_query/t/resultset/as_query.t 2009-05-07 09:55:12 UTC (rev 6158)
+++ DBIx-Class/0.08/branches/fix-update-and-delete-as_query/t/resultset/as_query.t 2009-05-07 09:58:14 UTC (rev 6159)
@@ -7,7 +7,7 @@
use Test::More;
-plan ( tests => 6 );
+plan ( tests => 4 );
use lib qw(t/lib);
use DBICTest;
@@ -65,21 +65,3 @@
[ [ rank => 2 ], [ name => 'Billy Joel' ] ],
);
}
-
-{
- my $rs = $schema->resultset("CD")->search(
- { 'artist.name' => 'Caterwauler McCrae' },
- { join => [qw/artist/]}
- );
- my $query = $rs->get_column('cdid')->as_query({ skip_parens => 1 });
- my ($sql, @bind) = @{$$query};
- is_same_sql_bind(
- $sql, \@bind,
- 'SELECT me.cdid FROM cd me JOIN artist artist ON artist.artistid = me.artist WHERE ( artist.name = ? )',
- [['artist.name' => 'Caterwauler McCrae']]
- );
- my $subsel_rs = $schema->resultset("CD")->search( { cdid => { IN => $query } } );
- is($subsel_rs->count, $rs->count, 'Subselect on PK got the same row count');
-}
-
-__END__
More information about the Bast-commits
mailing list