Postgres has it: http://www.postgresql.org/docs/9.2/static/queries-with.html Arel has it: http://www.ruby-doc.org/gems/docs/a/arel-3.0.2/Arel/SelectManager.html#method-i-with As far as I can tell, ActiveRecord doesn''t. I did a quick patch this morning for a local 3.2.13 project, and it seems to work great. I''d be happy to submit a PR if anyone else wants this (it will take a bit more time to do it properly, which is why I''m asking here first). Thanks guys! -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-core+unsubscribe@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at http://groups.google.com/group/rubyonrails-core?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
And how the others database adapters will work when you use `with`? I do not want to add database specific features in the Active Record public API. It may cause confusion. Rafael Mendonça França http://twitter.com/rafaelfranca https://github.com/rafaelfranca On Thu, May 9, 2013 at 6:52 PM, Joshua Wood <joshuawood@gmail.com> wrote:> Postgres has it: > http://www.postgresql.org/docs/9.2/static/queries-with.html > > Arel has it: > http://www.ruby-doc.org/gems/docs/a/arel-3.0.2/Arel/SelectManager.html#method-i-with > > As far as I can tell, ActiveRecord doesn''t. > > I did a quick patch this morning for a local 3.2.13 project, and it seems > to work great. I''d be happy to submit a PR if anyone else wants this (it > will take a bit more time to do it properly, which is why I''m asking here > first). > > Thanks guys! > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Core" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to rubyonrails-core+unsubscribe@googlegroups.com. > To post to this group, send email to rubyonrails-core@googlegroups.com. > Visit this group at http://groups.google.com/group/rubyonrails-core?hl=en. > For more options, visit https://groups.google.com/groups/opt_out. > > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-core+unsubscribe@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at http://groups.google.com/group/rubyonrails-core?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Much like textacular (https://github.com/textacular/textacular), make it a gem. -- Jarrett Meyer Email: jarrettmeyer@gmail.com Web: JarrettMeyer.com <http://jarrettmeyer.com> Twitter: @jarrettmeyer <http://twitter.com/jarrettmeyer> On Sat, May 11, 2013 at 11:08 PM, Rafael Mendonça França < rafaelmfranca@gmail.com> wrote:> And how the others database adapters will work when you use `with`? > > I do not want to add database specific features in the Active Record > public API. It may cause confusion. > > Rafael Mendonça França > http://twitter.com/rafaelfranca > https://github.com/rafaelfranca > > > On Thu, May 9, 2013 at 6:52 PM, Joshua Wood <joshuawood@gmail.com> wrote: > >> Postgres has it: >> http://www.postgresql.org/docs/9.2/static/queries-with.html >> >> Arel has it: >> http://www.ruby-doc.org/gems/docs/a/arel-3.0.2/Arel/SelectManager.html#method-i-with >> >> As far as I can tell, ActiveRecord doesn''t. >> >> I did a quick patch this morning for a local 3.2.13 project, and it seems >> to work great. I''d be happy to submit a PR if anyone else wants this (it >> will take a bit more time to do it properly, which is why I''m asking here >> first). >> >> Thanks guys! >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Ruby on Rails: Core" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to rubyonrails-core+unsubscribe@googlegroups.com. >> To post to this group, send email to rubyonrails-core@googlegroups.com. >> Visit this group at http://groups.google.com/group/rubyonrails-core?hl=en >> . >> For more options, visit https://groups.google.com/groups/opt_out. >> >> >> > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Core" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to rubyonrails-core+unsubscribe@googlegroups.com. > To post to this group, send email to rubyonrails-core@googlegroups.com. > Visit this group at http://groups.google.com/group/rubyonrails-core?hl=en. > For more options, visit https://groups.google.com/groups/opt_out. > > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-core+unsubscribe@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at http://groups.google.com/group/rubyonrails-core?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
I''d be interested in seeing your patch for this. If you''re not submitting a PR or making it into a gem, can you post a gist of it? Thanks On Thu, May 9, 2013 at 4:52 PM, Joshua Wood <joshuawood@gmail.com> wrote:> Postgres has it: > http://www.postgresql.org/docs/9.2/static/queries-with.html > > Arel has it: > http://www.ruby-doc.org/gems/docs/a/arel-3.0.2/Arel/SelectManager.html#method-i-with > > As far as I can tell, ActiveRecord doesn''t. > > I did a quick patch this morning for a local 3.2.13 project, and it seems > to work great. I''d be happy to submit a PR if anyone else wants this (it > will take a bit more time to do it properly, which is why I''m asking here > first). > > Thanks guys! > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Core" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to rubyonrails-core+unsubscribe@googlegroups.com. > To post to this group, send email to rubyonrails-core@googlegroups.com. > Visit this group at http://groups.google.com/group/rubyonrails-core?hl=en. > For more options, visit https://groups.google.com/groups/opt_out. > > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-core+unsubscribe@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at http://groups.google.com/group/rubyonrails-core?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Sorry, haven''t gotten around to the gem yet. Here''s the gist: https://gist.github.com/joshuap/5727554 I believe it will be slightly different for Rails 4. Here''s a very contrived example of using it: Post.with(Arel.sql(''found as (select id from posts where id in (1,2,3))'')).joins(''inner join found on found.id = posts.id'') Something needs to happen with escaping on the found sql, hence the `Arel.sql`. Josh On Tuesday, May 28, 2013 11:26:58 AM UTC-7, Andrew Kaspick wrote:> > I''d be interested in seeing your patch for this. If you''re not submitting > a PR or making it into a gem, can you post a gist of it? > > Thanks > > > On Thu, May 9, 2013 at 4:52 PM, Joshua Wood <joshu...@gmail.com<javascript:> > > wrote: > >> Postgres has it: >> http://www.postgresql.org/docs/9.2/static/queries-with.html >> >> Arel has it: >> http://www.ruby-doc.org/gems/docs/a/arel-3.0.2/Arel/SelectManager.html#method-i-with >> >> As far as I can tell, ActiveRecord doesn''t. >> >> I did a quick patch this morning for a local 3.2.13 project, and it seems >> to work great. I''d be happy to submit a PR if anyone else wants this (it >> will take a bit more time to do it properly, which is why I''m asking here >> first). >> >> Thanks guys! >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Ruby on Rails: Core" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to rubyonrails-co...@googlegroups.com <javascript:>. >> To post to this group, send email to rubyonra...@googlegroups.com<javascript:> >> . >> Visit this group at http://groups.google.com/group/rubyonrails-core?hl=en >> . >> For more options, visit https://groups.google.com/groups/opt_out. >> >> >> > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-core+unsubscribe@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at http://groups.google.com/group/rubyonrails-core?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
could you gist that code for me please, I''d like to take a look at it. On Thursday, May 9, 2013 5:52:42 PM UTC-4, Joshua Wood wrote:> > Postgres has it: > http://www.postgresql.org/docs/9.2/static/queries-with.html > > Arel has it: > http://www.ruby-doc.org/gems/docs/a/arel-3.0.2/Arel/SelectManager.html#method-i-with > > As far as I can tell, ActiveRecord doesn''t. > > I did a quick patch this morning for a local 3.2.13 project, and it seems > to work great. I''d be happy to submit a PR if anyone else wants this (it > will take a bit more time to do it properly, which is why I''m asking here > first). > > Thanks guys! >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-core+unsubscribe@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at http://groups.google.com/group/rubyonrails-core?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
He already provided a gist in his reply. On Sat, Jun 8, 2013 at 12:31 PM, James Pinto <tapgyn@gmail.com> wrote:> could you gist that code for me please, > I''d like to take a look at it. > > > On Thursday, May 9, 2013 5:52:42 PM UTC-4, Joshua Wood wrote: >> >> Postgres has it: http://www.postgresql.org/** >> docs/9.2/static/queries-with.**html<http://www.postgresql.org/docs/9.2/static/queries-with.html> >> >> Arel has it: http://www.ruby-doc.org/**gems/docs/a/arel-3.0.2/Arel/** >> SelectManager.html#method-i-**with<http://www.ruby-doc.org/gems/docs/a/arel-3.0.2/Arel/SelectManager.html#method-i-with> >> >> As far as I can tell, ActiveRecord doesn''t. >> >> I did a quick patch this morning for a local 3.2.13 project, and it seems >> to work great. I''d be happy to submit a PR if anyone else wants this (it >> will take a bit more time to do it properly, which is why I''m asking here >> first). >> >> Thanks guys! >> > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Core" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to rubyonrails-core+unsubscribe@googlegroups.com. > To post to this group, send email to rubyonrails-core@googlegroups.com. > Visit this group at http://groups.google.com/group/rubyonrails-core?hl=en. > For more options, visit https://groups.google.com/groups/opt_out. > > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-core+unsubscribe@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at http://groups.google.com/group/rubyonrails-core?hl=en. For more options, visit https://groups.google.com/groups/opt_out.