[Dbix-class] Need help with PgSQL fulltext search queries

Matt S Trout dbix-class at trout.me.uk
Mon May 11 17:27:50 GMT 2009


On Thu, May 07, 2009 at 10:28:51AM +0200, Moritz Onken wrote:
> 
> Am 07.05.2009 um 10:16 schrieb Alex Kapranoff:
> 
> >Good day to all!
> >
> >(this is either a DBIx::Class, SQL::Abstarct or PgSQL fulltext search
> >+ Perl question)
> >
> >Can someone please help "+selecting" a function with several  
> >parameters?
> >
> >This is the code we came up with. The problem is, $search_text doesn't
> >get quoted when sent to DB server.
> >
> >'+select'  => [
> >  \[q{ts_headline('ru', html, plainto_tsquery('ru', ?), 'StartSel =
> ><b>, StopSel = </b>')},
> >    [dummy => $search_text],
> >  ]],
> >'+as'   => ['html_hilited'],
> 
> Use dbh for quoting:
> 
> $search_text = $rs->result_source->schema->storage->dbh- 
> >quote($search_text);

WRONG. \[] obsoletes that approach.

The $search_text is passed as a bind value so no quoting should be required.

You need to dig deeper to work out what's going on ...

-- 
        Matt S Trout         Catalyst and DBIx::Class consultancy with a clue
     Technical Director      and a commit bit: http://shadowcat.co.uk/catalyst/
 Shadowcat Systems Limited
  mst (@) shadowcat.co.uk        http://shadowcat.co.uk/blog/matt-s-trout/



More information about the DBIx-Class mailing list