PostgreSQL 7.4.x/CDBI bug

[prev] [thread] [next] [Date index for 2005/02/27]

From: JJ Merelo
Subject: PostgreSQL 7.4.x/CDBI bug
Date: 10:12 on 27 Feb 2005
Hi,
I have mentioned before the error I had when upgrading to PostgreSQL
7.4.x and the latest version of the DBI/DBD::Pg drivers. Now I have
nailed down to a few bits of code.
Here's the table:
CREATE TABLE foo
(
  id serial NOT NULL,
  bar varchar(20)
)
--
Here's the module definition:
--
package Foo;

use strict;
use warnings;

use base 'Class::DBI::Pg';
use DBD::Pg qw(:pg_types);

__PACKAGE__->connection( "dbi:Pg:dbname=3Dtemplate1" );
__PACKAGE__->table('foo');
__PACKAGE__->columns( All =3D> qw( id bar ) );
__PACKAGE__->sequence( 'foo_id_seq' );
__PACKAGE__->data_type( id =3D> { pg_type =3D> 'int4'} );

'Sacab=F3'
--
Please note the undocumented (or at least, not found in Class::DBI
docs) data_type. What it does, deep down in the Class::DBI code, is to
bind a parameter to a type using bind_param($param-number,undef,type).
It does this correctly, as far as I understand, however, I can't drill
down from there since it seems to be XS code or whatever. I think I'm
doing this correctly, but it's hard to say.
And here's the test code:
--
#!/usr/bin/perl

use Test::More 'no_plan';

use Foo;

my $foo =3D Foo->find_or_create( { bar =3D> 'baz'} );
$foo->update();
$foo->dbi_commit();

isa_ok( $foo, 'Foo' );
is( $foo->bar, 'baz' );
--

It yields the usual "id is of type varchar when it should be of type
int" or suchlike (sorry I can't C&P, Linux and PG is in another
partition). However, I have bound explicitly id to its correct type;
problem is, it does not seem to pay attention to it, be it in
DBIx::ContextualFetch or at a higher level. I really don't know.
I don't know where can the problem be. It seems to be discarding
explicit type bindings. And I _really_ need this to work, or I'd had
to do a major refactoring discarding all numeric-type ids, so any help
will be much appreciated.

Thanks!

JJ

PostgreSQL 7.4.x/CDBI bug
JJ Merelo 10:12 on 27 Feb 2005

Re: PostgreSQL 7.4.x/CDBI bug
Cees Hek 14:41 on 27 Feb 2005

Re: PostgreSQL 7.4.x/CDBI bug
JJ Merelo 22:19 on 27 Feb 2005

Re: PostgreSQL 7.4.x/CDBI bug
JJ Merelo 22:45 on 27 Feb 2005

Re: PostgreSQL 7.4.x/CDBI bug
Cees Hek 00:23 on 28 Feb 2005

Re: PostgreSQL 7.4.x/CDBI bug
JJ Merelo 17:51 on 28 Feb 2005

Generated at 17:56 on 01 Mar 2005 by mariachi v0.52