Hi Jeremy,

I'm on PostgreSQL 12.2. See this link for a demo: 
https://dbfiddle.uk/?rdbms=postgres_12&fiddle=05f8e70165d7df9c9b19f0b5fb00f2c8

Basically, this is what I'm trying to do. Searching an email in jsonb 
field. But this email value can be partial. Due to this i need to use ilike 
%query% or regex.

I have one other query that I want to convert to Sequel but i fail on 
specific point. I just can't handle arrays. Is it possible to do so on 
Sequel or RAW?

Here is my query:

select t.*
from test_tbl t
where exists (select *
              from jsonb_array_elements_text(t.data -> 'alternate_emails') 
as t(email)
              where t.email like '%spence%');


In this query, i am able to handle jsonb function but not *as t(email)*.

On Saturday, April 25, 2020 at 12:57:08 AM UTC+3, Jeremy Evans wrote:
>
> On Friday, April 24, 2020 at 2:03:10 PM UTC-7, Dennis O'Connell wrote:
>>
>> Hello
>>
>> Is it possible to write or convert this query to Sequel? Or should I put 
>> as RAW SQL?
>>
>> select *
>> from members t
>> where data @? '$.alternate_emails[*] ? (@ like_regex ".*dennis.*")'
>>
>>
>> I couldn't find any documentation for query like this. I know, a bit 
>> complicated tho...
>>
>
> You should probably use raw SQL.  Sequel doesn't have DSL support for 
> XQuery syntax.  BTW, which database are you using that supports XQuery?
>
> Thanks,
> Jeremy
>

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/75a13740-3e0b-479a-9fa1-fd18f470aec4%40googlegroups.com.

Reply via email to