[Bast-commits] r9503 - in
DBIx-Class/0.08/branches/oracle_hierarchical_queries_rt39121/lib/DBIx/Class:
. SQLAHacks
ribasushi at dev.catalyst.perl.org
ribasushi at dev.catalyst.perl.org
Mon May 31 23:54:18 GMT 2010
Author: ribasushi
Date: 2010-06-01 00:54:17 +0100 (Tue, 01 Jun 2010)
New Revision: 9503
Modified:
DBIx-Class/0.08/branches/oracle_hierarchical_queries_rt39121/lib/DBIx/Class/ResultSet.pm
DBIx-Class/0.08/branches/oracle_hierarchical_queries_rt39121/lib/DBIx/Class/SQLAHacks.pm
DBIx-Class/0.08/branches/oracle_hierarchical_queries_rt39121/lib/DBIx/Class/SQLAHacks/Oracle.pm
Log:
Switch away from explicit count-attr lists - just delete what we do not need
Modified: DBIx-Class/0.08/branches/oracle_hierarchical_queries_rt39121/lib/DBIx/Class/ResultSet.pm
===================================================================
--- DBIx-Class/0.08/branches/oracle_hierarchical_queries_rt39121/lib/DBIx/Class/ResultSet.pm 2010-05-31 23:10:46 UTC (rev 9502)
+++ DBIx-Class/0.08/branches/oracle_hierarchical_queries_rt39121/lib/DBIx/Class/ResultSet.pm 2010-05-31 23:54:17 UTC (rev 9503)
@@ -1237,14 +1237,12 @@
my $rsrc = $self->result_source;
$attrs ||= $self->_resolved_attrs;
- # only take pieces we need for a simple count
- my $tmp_attrs = { map
- { $_ => $attrs->{$_} }
- qw/ alias from where bind join /
- };
+ my $tmp_attrs = { %$attrs };
+ # take off any limits, record_filter is cdbi, and no point of ordering nor locking a count
+ delete @{$tmp_attrs}{qw/rows offset order_by record_filter for/};
# overwrite the selector (supplied by the storage)
- $tmp_attrs->{select} = $rsrc->storage->_count_select ($rsrc, $tmp_attrs);
+ $tmp_attrs->{select} = $rsrc->storage->_count_select ($rsrc, $attrs);
$tmp_attrs->{as} = 'count';
my $tmp_rs = $rsrc->resultset_class->new($rsrc, $tmp_attrs)->get_column ('count');
@@ -1261,10 +1259,9 @@
my $rsrc = $self->result_source;
$attrs ||= $self->_resolved_attrs;
- my $sub_attrs = { map
- { $_ => $attrs->{$_} }
- qw/ alias from where bind join group_by having rows offset /
- };
+ my $sub_attrs = { %$attrs };
+ # extra selectors do not go in the subquery and there is no point of ordering it, nor locking it
+ delete @{$sub_attrs}{qw/collapse select _prefetch_select as order_by for/};
# if we multi-prefetch we group_by primary keys only as this is what we would
# get out of the rs via ->next/->all. We *DO WANT* to clobber old group_by regardless
@@ -1295,7 +1292,7 @@
->new ($rsrc, $sub_attrs)
->as_subselect_rs
->search ({}, { columns => { count => $rsrc->storage->_count_select ($rsrc, $attrs) } })
- -> get_column ('count');
+ ->get_column ('count');
}
sub _bool {
Modified: DBIx-Class/0.08/branches/oracle_hierarchical_queries_rt39121/lib/DBIx/Class/SQLAHacks/Oracle.pm
===================================================================
--- DBIx-Class/0.08/branches/oracle_hierarchical_queries_rt39121/lib/DBIx/Class/SQLAHacks/Oracle.pm 2010-05-31 23:10:46 UTC (rev 9502)
+++ DBIx-Class/0.08/branches/oracle_hierarchical_queries_rt39121/lib/DBIx/Class/SQLAHacks/Oracle.pm 2010-05-31 23:54:17 UTC (rev 9503)
@@ -24,20 +24,18 @@
$self->SUPER::new (\%opts);
}
-sub select {
- my ($self, $table, $fields, $where, $rs_attrs, @rest) = @_;
-
- my $sql = $self->SUPER::select($table, $fields, $where, $rs_attrs, @rest);
-
- return wantarray ? ($sql, @{$self->{from_bind}}, @{$self->{where_bind}}, @{$self->{_oracle_connect_by_binds}}, @{$self->{having_bind}}, @{$self->{order_bind}} ) : $sql;
+sub _assemble_binds {
+ my $self = shift;
+ return map { @{ (delete $self->{"${_}_bind"}) || [] } } (qw/from where oracle_connect_by having order/);
}
+
sub _emulate_limit {
my ( $self, $syntax, $sql, $rs_attrs, $rows, $offset ) = @_;
my ($cb_sql, @cb_bind) = $self->_connect_by($rs_attrs);
$sql .= $cb_sql;
- $self->{_oracle_connect_by_binds} = \@cb_bind;
+ $self->{oracle_connect_by_bind} = \@cb_bind;
return $self->SUPER::_emulate_limit($syntax, $sql, $rs_attrs, $rows, $offset);
}
Modified: DBIx-Class/0.08/branches/oracle_hierarchical_queries_rt39121/lib/DBIx/Class/SQLAHacks.pm
===================================================================
--- DBIx-Class/0.08/branches/oracle_hierarchical_queries_rt39121/lib/DBIx/Class/SQLAHacks.pm 2010-05-31 23:10:46 UTC (rev 9502)
+++ DBIx-Class/0.08/branches/oracle_hierarchical_queries_rt39121/lib/DBIx/Class/SQLAHacks.pm 2010-05-31 23:54:17 UTC (rev 9503)
@@ -508,8 +508,6 @@
sub select {
my ($self, $table, $fields, $where, $rs_attrs, @rest) = @_;
- $self->{"${_}_bind"} = [] for (qw/having from order where/);
-
if (not ref($table) or ref($table) eq 'SCALAR') {
$table = $self->_quote($table);
}
@@ -522,9 +520,18 @@
($sql, @{$self->{where_bind}}) = $self->SUPER::select(
$table, $self->_recurse_fields($fields), $where, $rs_attrs, @rest
);
- return wantarray ? ($sql, @{$self->{from_bind}}, @{$self->{where_bind}}, @{$self->{having_bind}}, @{$self->{order_bind}} ) : $sql;
+
+# this *must* be called, otherwise extra binds will remain in the sql-maker
+ my @bind = $self->_assemble_binds;
+
+ return wantarray ? ($sql, @bind) : $sql;
}
+sub _assemble_binds {
+ my $self = shift;
+ return map { @{ (delete $self->{"${_}_bind"}) || [] } } (qw/from where having order/);
+}
+
# Quotes table names, and handles default inserts
sub insert {
my $self = shift;
More information about the Bast-commits
mailing list