HI,
I'm trying to make a custom Q-like object as Malcolm recommended me. I
have this code:
class FT:
    def add_to_query( self, query, used_aliases ):
        select={
            'rank': "ts_rank_cd(tsv, query, 32)",
        }
        query.add_extra( select,None,('tsv @@
query',),None,None,None )

and I'm stuck with it. It's hard to understand the Query class
quickly.
I need a sql clause like this:
SELECT * FROM table, plainto_tsquery( %s ) as query WHERE tsv @@
query;
This is the simplest one.
I can't add 'plainto_tsquery( %s )' to extra tables since it renders
the content between double quotes.

Also, I try to use this class like the Q object:
items = Model.objects.filter( FT() )
FT should have a string argument to fill the content inside:
plainto_tsquery( %s )

Problems:
1.- This code fails. I get a TypeError, unpack non-sequence in line
914 of query.py:
arg, value = filter_expr
2.- I don't know how I can add: plainto_tsquery( %s ) to the sql
clause and make it work, it shouldn't be quoted.
3.-How can I pass the content to: plainto_tsquery( %s ) in order to
get: 'plainto_tsquery( 'words I want to search' )?

I'd appreciate your help.

Thank you.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@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-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to