Skip Menu |

This queue is for tickets about the Jifty-DBI CPAN distribution.

Report information
The Basics
Id: 39027
Status: new
Priority: 0/
Queue: Jifty-DBI

People
Owner: Nobody in particular
Requestors: sean [...] katron.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: DISTINCT ignored when using collection->count
Date: Fri, 05 Sep 2008 22:18:02 -0500
To: bug-Jifty-DBI [...] rt.cpan.org
From: Sean <sean [...] katron.org>
Using $collection->column( ..., function => 'DISTINCT' ) is ignored when trying to get a count of the result set. Failing test cast attached.
#!/usr/bin/env perl -w use strict; use warnings; use Test::More; BEGIN { require "t/utils.pl" } our (@available_drivers); use constant TESTS_PER_DRIVER => 4; my $total = scalar(@available_drivers) * TESTS_PER_DRIVER; plan tests => $total; foreach my $d ( @available_drivers ) { SKIP: { unless( has_schema( 'TestApp', $d ) ) { skip "No schema for '$d' driver", TESTS_PER_DRIVER; } unless( should_test( $d ) ) { skip "ENV is not defined for driver '$d'", TESTS_PER_DRIVER; } my $handle = get_handle( $d ); connect_handle( $handle ); isa_ok($handle->dbh, 'DBI::db'); {my $ret = init_schema( 'TestApp', $handle ); isa_ok($ret,'DBI::st', "Inserted the schema. got a statement handle back" );} my $count_all = init_data( 'TestApp::Term', $handle ); ok( $count_all, "init terms data" ); my $users_obj = TestApp::TermCollection->new( handle => $handle ); $users_obj->clean_slate; $users_obj->column( column => 'term', function => 'DISTINCT' ); $users_obj->limit( column => 'term', operator => 'MATCHES', value => 'foo'); is( $users_obj->count, 1, "one distinct row returned"); cleanup_schema( 'TestApp', $handle ); disconnect_handle( $handle ); }} # SKIP, foreach blocks 1; package TestApp; sub schema_mysql { <<EOF; CREATE TEMPORARY table terms ( id integer AUTO_INCREMENT, term varchar(18), author varchar(36), definition varchar(18), PRIMARY KEY (id)) EOF } sub schema_pg { <<EOF; CREATE TEMPORARY table terms ( id SERIAL PRIMARY KEY, term varchar(18), author varchar(36), definition varchar(18) ) EOF } sub schema_sqlite { <<EOF; CREATE table terms ( id integer primary key, term varchar(18), author varchar(36), definition varchar(18) ) EOF } sub schema_oracle { [ "CREATE SEQUENCE Terms_seq", "CREATE TABLE terms ( id integer CONSTRAINT terms_key PRIMARY KEY, term varchar(18), author varchar(36), definition varchar(18) )", ] } sub cleanup_schema_oracle { [ "DROP SEQUENCE terms_seq", "DROP TABLE terms", ] } 1; package TestApp::Term; use base qw/Jifty::DBI::Record/; sub _init { my $self = shift; $self->table('terms'); $self->SUPER::_init(@_); } sub init_data { return ( [ 'term', 'author', 'definition' ], [ 'foo', 'Sean', 'first item' ], [ 'foo', 'Shawn', 'bloop' ], ); } 1; BEGIN { use Jifty::DBI::Schema; use Jifty::DBI::Record schema { column term => type is 'varchar(18)'; column author => type is 'varchar(36)'; column definition => type is 'varchar(18)'; } } 1; package TestApp::TermCollection; # use TestApp::Term; use base qw/Jifty::DBI::Collection/; sub _init { my $self = shift; $self->SUPER::_init(@_); $self->table('terms'); } 1;