[Dbix-class] Pg bytea does not work

John Napiorkowski jjn1056 at yahoo.com
Mon Oct 15 15:14:09 GMT 2007


--- Rolf Schaufelberger <rs at plusw.de> wrote:

> On Montag 15 Oktober 2007, John Napiorkowski wrote:
> > --- Rolf Schaufelberger <rs at plusw.de> wrote:
> > > Hi,
> > >
> > > I have a table like this:
> > >  id              | integer                  |
> not
> > > null default
> > > nextval('orders.logos_id_seq'::regclass)
> > >  name            | character varying(100)   |
> > >  image           | bytea                    |
> > > ...
> > >
> > > and in my class I have
> > > ...
> > > __PACKAGE__->add_columns ( image => { data_type
> =>
> > > 'bytea' });
> > > ...
> > >
> > > Now when I try to insert something in image I
> get an
> > > error
> > >
> > > DBIx::Class::ResultSet::create(): DBI Exception:
> > > DBD::Pg::st execute failed:
> > > ERROR:  invalid byte sequence for encoding
> "UTF8":
> > >
> > > Debuggung showed me, that
> > >
> > > bind_attribute_by_data_type   is  called in
> > > D:C:Storage:DBI and not in D:C:Storage:DBI::Pg
> > >
> > > All my classes inherit from a base class which
> does
> > >
> > > __PACKAGE__->load_components(qw/Core PK::Auto/);
> > >
> > > Any idea ?
> > >
> > >
> > > I have DBD 1.4.9 and DBIx::Class 0.8 (just
> upgraded
> > > 5 min ago..)
> > > I have the same table running with Class::DBI
> anf
> > > now want to move to DBIC.
> > >
> > > --
> > > Regards
> > > Rolf Schaufelberger
> >
> > What version of the Postgresql database are you
> on?
> > I'm the culprit that wrote the section of code you
> > mentioned so I'm like to get more details.
> >
> > --john
> >
> its  8.1.9 on FreeBSD 6.2
> 
> In my old app with Class::DBI i use a setup like 
> __PACKAGE__->data_type(image => { pg_type =>
> DBD::Pg::PG_BYTEA })
> 
> that works, so don't think that it's an issue of the
> database version. 
> The question is, why  is  
> C.D.Storage::DBI::Pg::bind_attribute_by_data_type  
> not called ?
> 
> -- 
> Rolf Schaufelberger

That is awfully strange, since the Pg specific storage
should override it's base class...  But right now the
base class just returns, which probably isn't so
great.  I did that because I was too lazy to have the
base class return some sort of "Abstract Method"
exception and then have to add the method to each of
the consuming storage implementations.  I also didn't
want to break everyones stuff :)

I was thinking to rewrite this a bit so that the base
class did all the work and the subclasses just
responsible to define a mapping string.  That way it
would be easier for other storage maintainers to add
this sort of thing in.

So you've tried hacking the Pg storage class and have
verified that the method to create the parameter
bindings is not being called, but that it's base class
method is?  Can you try dumping what is being passed
to 'bind_attribute_by_data_type' on your system?  I'd
like to see it.

Also in the ..Storage::DBI package there is a method
called "source_bind_attributes" which is responsible
for calling the database specific parameter bindings. 
It does
'$self->bind_attribute_by_data_type($data_type)' and
I'd love to see what 'ref $self' looks like, since
that should be calling
DBIC::Storage::DBI::Pg->bind_attribute_by_data_type

Sorry to ask you to do all this debugging, but I'm at
a new jobsite today and don't have my machine setup
with all my test scripts and so forth yet.  I'll try
to hang out on IRC, btw.

--John

--John
> 
> _______________________________________________
> List:
>
http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
> IRC: irc.perl.org#dbix-class
> SVN:
> http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
> Searchable Archive:
>
http://www.grokbase.com/group/dbix-class@lists.rawmode.org
> 



       
____________________________________________________________________________________
Yahoo! oneSearch: Finally, mobile search 
that gives answers, not web links. 
http://mobile.yahoo.com/mobileweb/onesearch?refer=1ONXIC



More information about the DBIx-Class mailing list