Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Tables params in extra()
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  5 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Dave Lowe  
View profile  
 More options May 13 2008, 12:15 pm
From: Dave Lowe <dave.je...@gmail.com>
Date: Tue, 13 May 2008 09:15:23 -0700 (PDT)
Local: Tues, May 13 2008 12:15 pm
Subject: Tables params in extra()
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.


    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
David Cramer  
View profile  
 More options May 13 2008, 12:59 pm
From: David Cramer <dcra...@gmail.com>
Date: Tue, 13 May 2008 09:59:47 -0700 (PDT)
Local: Tues, May 13 2008 12:59 pm
Subject: Re: Tables params in extra()
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 <dave.je...@gmail.com> wrote:


    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dave Lowe  
View profile  
 More options May 13 2008, 1:47 pm
From: Dave Lowe <dave.je...@gmail.com>
Date: Tue, 13 May 2008 10:47:44 -0700 (PDT)
Local: Tues, May 13 2008 1:47 pm
Subject: Re: Tables params in extra()
It worked prior to qsrf-merge. I have tried adding the quotes though,
without success.

On May 13, 9:59 am, David Cramer <dcra...@gmail.com> wrote:


    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Barry Pederson  
View profile  
 More options May 14 2008, 12:01 am
From: Barry Pederson <b...@barryp.org>
Date: Tue, 13 May 2008 23:01:56 -0500
Local: Wed, May 14 2008 12:01 am
Subject: Re: Tables params in extra()

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


    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dave Lowe  
View profile  
 More options May 14 2008, 12:31 am
From: Dave Lowe <dave.je...@gmail.com>
Date: Tue, 13 May 2008 21:31:58 -0700 (PDT)
Local: Wed, May 14 2008 12:31 am
Subject: Re: Tables params in extra()
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 <b...@barryp.org> wrote:


    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2010 Google