[Bast-commits] r5443 - in DBIx-Class/0.08/branches/subquery:
lib/DBIx/Class lib/DBIx/Class/Storage/DBI t/resultset
robkinyon at dev.catalyst.perl.org
robkinyon at dev.catalyst.perl.org
Tue Feb 10 20:23:27 GMT 2009
Author: robkinyon
Date: 2009-02-10 20:23:27 +0000 (Tue, 10 Feb 2009)
New Revision: 5443
Modified:
DBIx-Class/0.08/branches/subquery/lib/DBIx/Class/ResultSet.pm
DBIx-Class/0.08/branches/subquery/lib/DBIx/Class/ResultSetColumn.pm
DBIx-Class/0.08/branches/subquery/lib/DBIx/Class/Storage/DBI/Cursor.pm
DBIx-Class/0.08/branches/subquery/t/resultset/as_query.t
Log:
Added as_query() support to ResultSetColumn
Modified: DBIx-Class/0.08/branches/subquery/lib/DBIx/Class/ResultSet.pm
===================================================================
--- DBIx-Class/0.08/branches/subquery/lib/DBIx/Class/ResultSet.pm 2009-02-10 20:10:10 UTC (rev 5442)
+++ DBIx-Class/0.08/branches/subquery/lib/DBIx/Class/ResultSet.pm 2009-02-10 20:23:27 UTC (rev 5443)
@@ -1711,6 +1711,14 @@
=head2 as_query
+=over 4
+
+=item Arguments: none
+
+=item Return Value: [ $sql, @bind ]
+
+=back
+
Returns the SQL query and bind vars associated with the invocant.
=cut
Modified: DBIx-Class/0.08/branches/subquery/lib/DBIx/Class/ResultSetColumn.pm
===================================================================
--- DBIx-Class/0.08/branches/subquery/lib/DBIx/Class/ResultSetColumn.pm 2009-02-10 20:10:10 UTC (rev 5442)
+++ DBIx-Class/0.08/branches/subquery/lib/DBIx/Class/ResultSetColumn.pm 2009-02-10 20:23:27 UTC (rev 5443)
@@ -54,6 +54,22 @@
return $new;
}
+=head2 as_query
+
+=over 4
+
+=item Arguments: none
+
+=item Return Value: [ $sql, @bind ]
+
+=back
+
+Returns the SQL query and bind vars associated with the invocant.
+
+=cut
+
+sub as_query { return shift->_resultset->as_query }
+
=head2 next
=over 4
@@ -278,7 +294,6 @@
);
}
-
1;
=head1 AUTHORS
Modified: DBIx-Class/0.08/branches/subquery/lib/DBIx/Class/Storage/DBI/Cursor.pm
===================================================================
--- DBIx-Class/0.08/branches/subquery/lib/DBIx/Class/Storage/DBI/Cursor.pm 2009-02-10 20:10:10 UTC (rev 5442)
+++ DBIx-Class/0.08/branches/subquery/lib/DBIx/Class/Storage/DBI/Cursor.pm 2009-02-10 20:23:27 UTC (rev 5443)
@@ -51,6 +51,14 @@
=head2 as_query
+=over 4
+
+=item Arguments: none
+
+=item Return Value: [ $sql, @bind ]
+
+=back
+
Returns the SQL statement and bind vars associated with the invocant.
=cut
Modified: DBIx-Class/0.08/branches/subquery/t/resultset/as_query.t
===================================================================
--- DBIx-Class/0.08/branches/subquery/t/resultset/as_query.t 2009-02-10 20:10:10 UTC (rev 5442)
+++ DBIx-Class/0.08/branches/subquery/t/resultset/as_query.t 2009-02-10 20:23:27 UTC (rev 5443)
@@ -7,7 +7,7 @@
use lib qw(t/lib);
use DBICTest;
-plan tests => 6;
+plan tests => 8;
my $schema = DBICTest->init_schema();
my $art_rs = $schema->resultset('Artist');
@@ -40,4 +40,14 @@
is_deeply( \@bind, [ [ rank => 2 ], [ name => 'Billy Joel' ] ] );
}
+my $rscol = $art_rs->get_column( 'charfield' );
+
+{
+ my $arr = $rscol->as_query;
+ my ($query, @bind) = @$arr;
+
+ is( $query, "SELECT me.charfield FROM artist me WHERE ( ( ( rank = ? ) AND ( name = ? ) ) )" );
+ is_deeply( \@bind, [ [ rank => 2 ], [ name => 'Billy Joel' ] ] );
+}
+
__END__
More information about the Bast-commits
mailing list