I can't tell you how grateful I am that you posted this workaround,
Barry! Just in time for a site launch.
Like you said, I wonder if the multiple calls to to_tsquery() are
acceptable or if there's a more graceful solution here for the long-
term.
On May 13, 9:01 pm, Barry Pederson <[EMAIL PROTECTED]> wrote:
> Dave Lowe wrote:
> > It worked prior to qsrf-merge. I have tried adding the quotes though,
> > without success.
>
> > On May 13, 9:59 am, David Cramer <[EMAIL PROTECTED]> wrote:
> >> The database engine usually can't fill that in anyways, you should
> >> probably quote it yourself (correct me if I'm wrong).
>
> >> On May 13, 9:15 am, Dave Lowe <[EMAIL PROTECTED]> wrote:
>
> >>> Ever since the querset-refactor merge, params in the 'tables' argument
> >>> don't seem to be filled. The documentation describes the arguments
> >>> 'params' and 'select_params' as being for where and select statements,
> >>> respectively. Do we need a "tables_params" argument as well?
> >>> Here's a code sample of where I'm using tables params (it's for full-
> >>> text searching in postgres):
> >>> results = Product.objects.extra(
> >>> select={
> >>> 'rank': "rank_cd(textsearchable,
> >>> query, 32)",
> >>> },
> >>> tables=["to_tsquery(%s) as query"],
> >>> where=["textsearchable @@ query"],
> >>> params=[terms],
> >>> order_by=('-rank',)
> >>> )
> >>> The error message by the way is: ProgrammingError: relation
> >>> "to_tsquery(2) as query" does not exist.
>
> I've seen this too, also trying to do PgSQL FTS, and posted about it in
> django-users
>
> http://groups.google.com/group/django-users/browse_thread/thread/ef17...
>
> it seems that two things are changed from pre-QSRF: params aren't
> processed for the 'tables=' argument, and the tables= arguments are
> quoted now, so you end up with something like
>
> SELECT ... FROM "to_tsquery(%s) as query" ...
>
> where before QSRF it would have executed
>
> SELECT ... FROM to_tsquery('value of terms') as query ...
>
> as a workaround, you can repeat the call to to_tsquery() and use
> select_params=, as in:
>
>
>
> results = Product.objects.extra(
> select={
> 'rank': "rank_cd(textsearchable,to_tsquery(%s), 32)",
> },
> where=["textsearchable @@ to_tsquery(%s)"],
> params=[terms],
> select_params=[terms],
> order_by=('-rank',)
> )
>
> -
>
> Don't know how big of a hit it is to have to call to_tsquery() multiple
> times even with the same args. But this isn't really just a fulltext
> search issue, it could come up with other PgSQL functions that are more
> heavyweight.
>
> Barry
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-developers?hl=en
-~--~~~~--~~--~--~---