[Bast-commits] r6596 - in
DBIx-Class/0.08/branches/sybase/lib/DBIx/Class/Storage: . DBI
caelum at dev.catalyst.perl.org
caelum at dev.catalyst.perl.org
Wed Jun 10 12:35:53 GMT 2009
Author: caelum
Date: 2009-06-10 12:35:52 +0000 (Wed, 10 Jun 2009)
New Revision: 6596
Modified:
DBIx-Class/0.08/branches/sybase/lib/DBIx/Class/Storage/DBI.pm
DBIx-Class/0.08/branches/sybase/lib/DBIx/Class/Storage/DBI/Sybase.pm
Log:
Sybase count by first pk, if available
Modified: DBIx-Class/0.08/branches/sybase/lib/DBIx/Class/Storage/DBI/Sybase.pm
===================================================================
--- DBIx-Class/0.08/branches/sybase/lib/DBIx/Class/Storage/DBI/Sybase.pm 2009-06-10 12:04:19 UTC (rev 6595)
+++ DBIx-Class/0.08/branches/sybase/lib/DBIx/Class/Storage/DBI/Sybase.pm 2009-06-10 12:35:52 UTC (rev 6596)
@@ -81,10 +81,12 @@
my $offset = $attrs->{offset} || 0;
my $total = $attrs->{rows} + $offset;
- my $new_attrs = $self->_trim_attributes_for_count($source, $attrs);
- $new_attrs->{select} = '1';
- $new_attrs->{as} = ['dummy'];
+ my $new_attrs = $self->_copy_attributes_for_count($source, $attrs);
+ my $first_pk = ($source->primary_columns)[0];
+
+ $new_attrs->{select} = $first_pk ? "me.$first_pk" : 1;
+
my $tmp_rs = $source->resultset_class->new($source, $new_attrs);
$self->dbh->{syb_rowcount} = $total;
Modified: DBIx-Class/0.08/branches/sybase/lib/DBIx/Class/Storage/DBI.pm
===================================================================
--- DBIx-Class/0.08/branches/sybase/lib/DBIx/Class/Storage/DBI.pm 2009-06-10 12:04:19 UTC (rev 6595)
+++ DBIx-Class/0.08/branches/sybase/lib/DBIx/Class/Storage/DBI.pm 2009-06-10 12:35:52 UTC (rev 6596)
@@ -1325,7 +1325,7 @@
return $alias2source;
}
-sub _trim_attributes_for_count {
+sub _copy_attributes_for_count {
my ($self, $source, $attrs) = @_;
my %attrs = %$attrs;
@@ -1338,7 +1338,7 @@
sub count {
my ($self, $source, $attrs) = @_;
- my $tmp_attrs = $self->_trim_attributes_for_count($source, $attrs);
+ my $tmp_attrs = $self->_copy_attributes_for_count($source, $attrs);
# overwrite the selector
$tmp_attrs->{select} = { count => '*' };
More information about the Bast-commits
mailing list