Re: What is the best way of creating GIN INDEX

2019-05-24 Thread Jeremy Evans
On Friday, May 24, 2019 at 10:39:48 AM UTC-7, xura wrote: > > Hi, > > Following is an :gin index for jsonb fields: > > CREATE INDEX index_name > ON public.emails > USING gin > (send_cc, send_bcc, send_to, sender); > > So, in Sequel docs no :Gin mentioned. Is there a better way to do this >

What is the best way of creating GIN INDEX

2019-05-24 Thread xura
Hi, Following is an :gin index for jsonb fields: CREATE INDEX index_name ON public.emails USING gin (send_cc, send_bcc, send_to, sender); So, in Sequel docs no :Gin mentioned. Is there a better way to do this without writing RAW SQL inside migrations? -- You received this message

Re: jsonb, LATERAL and DISTINCT query with sequel

2019-05-24 Thread xura
Thanks Jeremy. It works! On Friday, May 24, 2019 at 5:28:28 PM UTC+3, Jeremy Evans wrote: > > On Friday, May 24, 2019 at 6:22:53 AM UTC-7, xura wrote: >> >> In fact, query is now like this: >> >> SELECT DISTINCT ON (jj->>'email') jj->>'email', jj->>'name' , count(*) >> over(partition by

Re: `RcteTree` plugin with `eager_graph`

2019-05-24 Thread Alexander Popov
OK, thanks. On Friday, May 24, 2019 at 5:46:30 PM UTC+3, Jeremy Evans wrote: > > On Monday, May 20, 2019 at 12:59:52 PM UTC-7, Jeremy Evans wrote: >> >> Not a bug in eager_graph, it is just that associations that use CTEs >> cannot be graphed. We should probably raise an exception if you try to

Re: `RcteTree` plugin with `eager_graph`

2019-05-24 Thread Jeremy Evans
On Monday, May 20, 2019 at 12:59:52 PM UTC-7, Jeremy Evans wrote: > > Not a bug in eager_graph, it is just that associations that use CTEs > cannot be graphed. We should probably raise an exception if you try to use > eager_graph, though. I'll try to make that change before the next release.

Re: jsonb, LATERAL and DISTINCT query with sequel

2019-05-24 Thread Jeremy Evans
On Friday, May 24, 2019 at 6:22:53 AM UTC-7, xura wrote: > > In fact, query is now like this: > > SELECT DISTINCT ON (jj->>'email') jj->>'email', jj->>'name' , count(*) > over(partition by jj->>'email' ) > from emails > join lateral jsonb_array_elements(send_to) j(jj) on true > ORDER BY

Re: Question about placeholders / binds from arrays of data

2019-05-24 Thread Allan Peda
That's what I am doing. Thanks, I just wanted to be sure I did not miss anything. On Friday, May 24, 2019 at 10:21:06 AM UTC-4, Jeremy Evans wrote: > > On Friday, May 24, 2019 at 6:48:52 AM UTC-7, Allan Peda wrote: >> >> Hi, >> >> I am using Sequel mostly for the convenience of bind variables

Re: Question about placeholders / binds from arrays of data

2019-05-24 Thread Jeremy Evans
On Friday, May 24, 2019 at 6:48:52 AM UTC-7, Allan Peda wrote: > > Hi, > > I am using Sequel mostly for the convenience of bind variables (with > MSSQL/tiny_tds). > > I see positional binds are possible with a straight SQL call, as in: > > arr = [33, 26, 33] > sth = dbh['insert into mytab(a, b,

Question about placeholders / binds from arrays of data

2019-05-24 Thread Allan Peda
Hi, I am using Sequel mostly for the convenience of bind variables (with MSSQL/tiny_tds). I see positional binds are possible with a straight SQL call, as in: arr = [33, 26, 33] sth = dbh['insert into mytab(a, b, c) values (?, ?, ?)', *arr] sth.call(:insert) Is there any way to set the binds

Re: jsonb, LATERAL and DISTINCT query with sequel

2019-05-24 Thread xura
In fact, query is now like this: SELECT DISTINCT ON (jj->>'email') jj->>'email', jj->>'name' , count(*) over(partition by jj->>'email' ) from emails join lateral jsonb_array_elements(send_to) j(jj) on true ORDER BY jj->>'email', id desc On Friday, May 24, 2019 at 12:55:01 PM UTC+3, xura

Re: jsonb, LATERAL and DISTINCT query with sequel

2019-05-24 Thread xura
I've achieved similar query by this: .select(to.get_text('email').as(:email), to.get_text('name').as(:name)) .cross_join(Sequel.function(:jsonb_array_elements, :receiver).lateral) .order(Sequel.desc(to.get_text('email')), Sequel.desc(:id)) .distinct(to.get_text('email')) However, i couldn't

jsonb, LATERAL and DISTINCT query with sequel

2019-05-24 Thread genc
Hi, Is it possible to write this query with Sequel? SELECT DISTINCT ON (x.e->>'email') x.e->>'email' as email, x.e->>'name' as name FROM messages sr CROSS JOIN LATERAL jsonb_array_elements(sr.receiver) x (e) ORDER BY x.e->>'email', id desc Or I use

jsonb, LATERAL and DISTINCT query with sequel

2019-05-24 Thread xura
Hi, Is it possible to write this query with Sequel? SELECT DISTINCT ON (x.e->>'email') x.e->>'email' as email, x.e->>'name' as name FROM messages sr CROSS JOIN LATERAL jsonb_array_elements(sr.receiver) x (e) ORDER BY x.e->>'email', id desc Or I use