Loading...

thinking-sphinx@googlegroups.com

[Prev] Thread [Next]  |  [Prev] Date [Next]

[ts] Re: Cannot index with STI and PgSQL Pat Allan Mon Dec 29 01:03:52 2008

Okay, 'this week' became 'this year', but I've finally put this fix  
into production. Although I don't have PG 8.2 to test with (but I've  
made sure it's compatable with 8.3 as well), so if someone can test  
for that easily, that'd be muchly appreciated.

-- 
Pat

On 02/11/2008, at 8:41 PM, Pat Allan wrote:

>
> Ah, good detective work!
>
> We should be able to add a workaround, like we're doing for another
> generated function:
> http://github.com/freelancing-god/thinking-sphinx/tree/master/lib/thinking_sphinx/adapters/postgresql_adapter.rb#L16
>
> I'll just need to get my head in PG mode to sort it out - hopefully
> sometime this week.
>
> Cheers
>
> -- 
> Pat
>
> On 02/11/2008, at 4:05 PM, Michael Siebert wrote:
>
>> After some research on PgSQL I've found out that PgSQL < 8.3 cannot
>> cast text to bytea.
>> WTF?
>> Hope we can change to mysql soon :)
>> But I've found a workaround
>>
>>> select (decode(replace(type, '\\', '\\\\'), 'escape')) from
>> contacts;
>> from http://bytes.com/forum/thread174532.html
>>
>> I don't know how this works, but it works. So either distinguish
>> between the postgres versions OR
>> document that postgres < 8.3 does not work with sti at all (and
>> please update the peepcode pdf accordingly)
>>
>> man, this sucks...
>>
>> how would one distinguish between 8.2 and 8.3 in ActiveRecord?
>>
>> Am 02.11.2008 um 09:13 schrieb Pat Allan:
>>
>>>
>>> Right. Maybe 8.2.x doesn't like casting text to byte arrays... (I'm
>>> using 8.3.1)
>>>
>>> I'm no PG expert though. Is text different to string? (I'm thinking
>>> blob versus varchar in mysql). When you declared the type column in
>>> your STI table in migrations, was it :string or :text? If the  
>>> latter,
>>> try changing it to :string, see if that helps?
>>>
>>> -- 
>>> Pat
>>>
>>> On 02/11/2008, at 2:55 PM, Michael Siebert wrote:
>>>
>>>> Hi Pat,
>>>>
>>>> I'm using installed via some mysterious MacOS-Package (don't now
>>>> anymore where I've got that from...)
>>>>
>>>> # psql --version
>>>> psql (PostgreSQL) 8.2.3
>>>>
>>>> Am 02.11.2008 um 07:43 schrieb Pat Allan:
>>>>
>>>>>
>>>>> Hi Michael
>>>>>
>>>>> It shouldn't be a problem having the index in the subclass. Seems
>>>>> like
>>>>> the PostgreSQL crc function (generated by ThinkingSphinx) isn't
>>>>> happy
>>>>> with the conversion - what version of PostgreSQL are you using?
>>>>>
>>>>> -- 
>>>>> Pat
>>>>>
>>>>> On 02/11/2008, at 12:56 AM, Michael Siebert wrote:
>>>>>
>>>>>>
>>>>>> Hi there, i've got a problem with indexing in subclasses of STI
>>>>>> models
>>>>>>
>>>>>> class Contact < AR::Base
>>>>>> end
>>>>>>
>>>>>> class HealerContact < Contact
>>>>>> define_index do
>>>>>> indexes last_name, :as => :name
>>>>>> end
>>>>>> end
>>>>>>
>>>>>> when i run rake ts:index, i get
>>>>>>
>>>>>> ERROR: index 'healer_contact_core': sql_range_query: ERROR:
>>>>>> cannot
>>>>>> cast type text to bytea
>>>>>> LINE 1: SELECT  ( $1  # get_byte( $2 ::bytea,  $3 ))::bigint
>>>>>>                                  ^
>>>>>> QUERY:  SELECT  ( $1  # get_byte( $2 ::bytea,  $3 ))::bigint
>>>>>> CONTEXT:  PL/pgSQL function "crc32" line 8 at assignment
>>>>>>
>>>>>> the config it generates is at http://pastie.org/305530
>>>>>>
>>>>>> what am i doing wrong? is it a problem, that i only index the
>>>>>> subclass
>>>>>> and not the base class?
>>>>>>
>>>>>>>
>>>>>
>>>>>
>>>>>>>
>>>>
>>>> ---
>>>> Siebert WD
>>>> Michael Siebert
>>>> Trappenweg 6, 15749 Mittenwalde, Deutschland
>>>>
>>>
>>>
>>>>>
>>
>> ---
>> Siebert WD
>> Michael Siebert
>> Trappenweg 6, 15749 Mittenwalde, Deutschland
>>
>
>
> >


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Thinking Sphinx" group.
To post to this group, send email to [EMAIL PROTECTED]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/thinking-sphinx?hl=en
-~----------~----~----~----~------~----~------~--~---