Skip Menu |

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

Report information
The Basics
Id: 35085
Status: new
Priority: 0/
Queue: Class-DBI-Sweet

People
Owner: Nobody in particular
Requestors: fenlisesi [...] gmail.com
Cc:
AdminCc:

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



Subject: (int4) bind type picked for Pg varchar column.
This is related to RT#34885: http://rt.cpan.org/Public/Bug/Display.html?id=34885 which, in turn, references RT#34840: http://rt.cpan.org/Public/Bug/Display.html?id=34840 Below is a test script that recreates the problem. The test script may have errors in it, as I just wrote it and did not have much chance to test/study it. If so, please point out the problems and I will send in a cleaner one when I come in to the office in the morning. I first tried to just patch one of the CDBI::Sweet's own tests, as I thought that would be the easiest route for you guys. However, I found that the problem happens with a Pg driver, and not with SQLite. Cheers ============================================================== #!/usr/local/bin/perl5.10.0 -wT ##----------------------------------------------------------------------+ package MyApp::DBI; use base 'Class::DBI::Sweet'; sub SQL_SETUP () {q{ CREATE TABLE cd (cdid INTEGER NOT NULL PRIMARY KEY, title VARCHAR); INSERT INTO cd (cdid, title) VALUES (1, 'Spoonful of bees'); INSERT INTO cd (cdid, title) VALUES (2, 'Forkful of bees'); INSERT INTO cd (cdid, title) VALUES (3, 'Caterwauling Blues'); INSERT INTO cd (cdid, title) VALUES (4, 'Generic Manufactured Singles'); };}; sub myapp_connection { my ($self) = @_; my $class = ref( $self ) || $self; $class->connection( $self->myapp_dsn(), $self->myapp_db_user(), $self->myapp_db_pass(), ); $class->db_Main->do( $_ ) for split( /\n\n/, SQL_SETUP ); } ##----------------------------------------------------------------------+ package MyApp::Article; use base 'MyApp::DBI'; __PACKAGE__->table('cd'); __PACKAGE__->columns( Primary => qw[ cdid ] ); __PACKAGE__->columns( Essential => qw[ title ] ); ##----------------------------------------------------------------------+ package MyApp::Article::Pg; use base 'MyApp::Article'; sub myapp_dsn {'DBI:Pg:dbname=rt34885;host=127.0.0.1;port=5432'}; sub myapp_db_user {'postgres'}; sub myapp_db_pass {'postgres'}; ##----------------------------------------------------------------------+ package MyApp::Article::SQLite; use base 'MyApp::Article'; sub DB_FILE () {'rt34885.db'}; unlink( DB_FILE ) if -e DB_FILE; unlink( DB_FILE . "-journal") if -e DB_FILE . "-journal"; sub myapp_dsn {'dbi:SQLite:'.DB_FILE}; sub myapp_db_user {q()}; sub myapp_db_pass {q()}; ##----------------------------------------------------------------------+ package main; use strict; use warnings; use Test::More; use Data::Dumper; plan tests => 4; sub query_gen { my ($aref) = @_; [ '-and', [ [ '-or', [ {'title' => { -like => '%Manufactured%'} }, {'cdid' => {'-in' => $aref}}, ] ], [ '-or', [ {'title' => { -like => '%Generic%'} }, {'cdid' => {'-in' => $aref}}, ] ], ] ]; } my ($page, $iter); my ($q_12, $q_123) = (query_gen( [1,2] ), query_gen( [1,2,3] )); MyApp::Article::SQLite->myapp_connection(); ($page, $iter) = MyApp::Article::SQLite->page( $q_12 ); is( $iter->count, 3, 'fenLisesi rt34885, sqlite, [1,2]' ); ($page, $iter) = MyApp::Article::SQLite->page( $q_123 ); is( $iter->count, 4, 'fenLisesi rt34885, sqlite, [1,2,3]' ); MyApp::Article::Pg->myapp_connection(); ($page, $iter) = MyApp::Article::Pg->page( $q_12 ); is( $iter->count, 3, 'fenLisesi rt34885, postgres, [1,2]' ); ($page, $iter) = MyApp::Article::Pg->page( $q_123 ); is( $iter->count, 4, 'fenLisesi rt34885, postgres, [1,2,3]' ); __END__