[Dbix-class] Branch for supporting column attributes checked in

John Napiorkowski jjn1056 at yahoo.com
Tue Nov 21 15:52:33 GMT 2006


--- Jon Warbrick <jw35 at cam.ac.uk> wrote:

> On Fri, 17 Nov 2006, John Napiorkowski wrote:
> 
> > ...
> > This is sorely needed by people trying to get
> > Postgresql BYTEA and Oracle BLOB columns to work
> > without having to hack around.
> 
> Pending an agreement on how to get column attributes
> working, and this 
> functionality arriving in the distribution, does
> anyone have a suggestion 
> for the best hack for getting BYTEA columns working
> in Postgresql?
> 
> Jon.

Here's a working example for doing updates on a column
called 'media' which is BYTEA.  Basically you just
need to hint that this is a BYTEA column.

sub mediafile
{
  my ($self, $val) = @_;
  
  if($val)
  {
    my $sth =
$self->result_source->schema->storage->dbh->prepare("update
		membership.media set media = ? where media_id = ?");
    $sth->bind_param(1,$val, { pg_type =>
DBD::Pg::PG_BYTEA });
    $sth->bind_param(2,$self->media_id());
    $sth->execute();
  }
	
  my $f =
$self->result_source->schema->storage->dbh->prepare("select
	media from membership.media where media_id = ?");

  $f->execute($self->media_id());
  my $hash = $f->fetchrow_hashref();
  return $hash->{media};
}

Creds to  Jesper Krogh for this, it's basically a copy
of something he posted a few months ago.

Rember to "use DBD::Pg qw(:pg_types);" at the top of
your module.

However...

I would personally appreciate you trying out what I
currently have on the dev repository.  It actually
works (for me), just right now requires some
additional stuff in your column_info, which is not so
desirable.

If you need some help getting it downloaded or setting
up your system so that you can switch between this
version and the current CPAn version I am happy to
help out, just message me directly.  I'd like to get
some additional testing on this to see what else it
might break.

There's not compiling or anything that you'd need to
do.  It's pretty straightforward.

Thanks!
John




 
____________________________________________________________________________________
Sponsored Link

Mortgage rates near 39yr lows. $510k for $1,698/mo. 
Calculate new payment! www.LowerMyBills.com/lre



More information about the Dbix-class mailing list