[Dbix-class] 08100: branch roundup, owners please respond.

John Napiorkowski jjn1056 at yahoo.com
Tue Apr 1 02:17:26 BST 2008


--- John Napiorkowski <jjn1056 at yahoo.com> wrote:

> 
> --- Matt S Trout <dbix-class at trout.me.uk> wrote:
> 
> > On Tue, Mar 11, 2008 at 02:07:24PM -0700, John
> > Napiorkowski wrote:
> > > 
> > > --- Matt S Trout <dbix-class at trout.me.uk> wrote:
> > > 
> > > > versioned and cdbicompat are merged to trunk.
> > > > 
> > > > that leaves -
> > > > 
> > > > alias_length_limit
> > > > bindtype_ensure_connected
> > > 
> > > That's mine.  It's a branch to make sure the
> > database
> > > is connected if you are specifying a custom bind
> > type.
> > >  I'm stuck because it looks like the latest
> > version of
> > > Postgresql actually solves the problem of
> needing
> > bind
> > > types to support blobs properly.  I need a bit
> of
> > time
> > > to set up a new virtual machine with the older
> > version
> > > of postgresql to run my tests against.  I'll
> > should be
> > > able to work on that later this month.  It's a
> low
> > > priority bug fix, just that if your very first
> > query
> > > is one that needs the bind types it will blow
> up. 
> > > There is a workaround of forcing ensure
> connected.
> >  
> > 
> > I think we were looking at forcing
> ensure_connected
> > right at the top of any
> > method that could possibly need this stuff.
> > 
> > I think the storage should really be able to just
> > assume it.
> > 
> > Could you have a poke around?
> 
> Yeah, I think that's really the best idea, rather
> than
> stick ensure_connected all over the place.   Let me
> do
> a list of where I think it's needed and then I'll
> bounce it on the list and see anything thinks I
> missed
> something.  --john
> 

Okay, so I think this is actually much easier than I
first thought.  Basically since I know that each
storage specific subclass inherits from
DBIx::Class::Storage::DBI I just put a stublike method
there which performs the connection and redispatches
to the subclass on an as needed basis.

So for example, if a storage specific subclass needs
to define bind parameters, such as how the Pg Storage
subclasses needs to set bytea bind parameters to
support using bytea for long/blob storage, it
overrides the method "bind_attribute_by_data_type"
from DBIx::Class::Storage::DBI like so:

sub bind_attribute_by_data_type {
  my ($self,$data_type) = @_;

  my $bind_attributes = {
    bytea => { pg_type => DBD::Pg::PG_BYTEA },
  };
 
  if( defined $bind_attributes->{$data_type} ) {
    return $bind_attributes->{$data_type};
  }
  else {
    return;
  }
}

and in the parent class I have a version which, if
executed, performs the connection and then sends it
off to the storage specific subclass:

sub bind_attribute_by_data_type {
  my ($self, $data_type, $storage) = @_;
  if($storage) {
    $storage->ensure_connected;
    return
$storage->bind_attribute_by_data_type($data_type)
  }
  return;
}

I think this is a strategy we could use for other
similar times when we have this problem, when we need
to have storage specific functions and have to be sure
that the storage is connected.  My code is in the
'bindtype_ensure_connected' branch. It passes all the
tests but I am wondering if anyone sees a performance
related or other kind of problem?

Thanks for feedback, sorry this branch sat around so
long. Hopefully if no one finds any trouble we can
close this issue out.

--john


> > 
> > -- 
> >       Matt S Trout       Need help with your
> > Catalyst or DBIx::Class project?
> >    Technical Director                   
> > http://www.shadowcat.co.uk/catalyst/
> >  Shadowcat Systems Ltd.  Want a managed
> development
> > or deployment platform?
> > http://chainsawblues.vox.com/           
> > http://www.shadowcat.co.uk/servers/
> > 
> > _______________________________________________
> > 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
> > 
> 
> 
> 
>      
>
____________________________________________________________________________________
> Looking for last minute shopping deals?  
> Find them fast with Yahoo! Search. 
>
http://tools.search.yahoo.com/newsearch/category.php?category=shopping
> 
> _______________________________________________
> 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
> 



      ____________________________________________________________________________________
No Cost - Get a month of Blockbuster Total Access now. Sweet deal for Yahoo! users and friends. 
http://tc.deals.yahoo.com/tc/blockbuster/text1.com



More information about the DBIx-Class mailing list