I agree, current approach is not the most convenient one. Have you considered how would you handle more complex queries, ones where each OR operand is more than a single equality comparison?
For example: SELECT * FROM authors WHERE (first_name = 'John' OR last_name = 'Smith') OR (company LIKE '%rails' AND dob BETWEEN '...' AND '...') Best, On Thu, Oct 10, 2019 at 2:22 PM Vicente Romero Calero <vterom...@gmail.com> wrote: > Consider the following simple query: > > SELECT * FROM authors WHERE first_name = 'John' OR last_name = 'Smith' > > With ActiveRecord you can write it like this: > > Author.where(first_name: 'John').or(Author.where(last_name: 'Smith')) > > It’s annoying that you need to pass in a whole relation to the `or` > function. It would be nicer to have something shorter and cleaner. So, I > propose to add a `where.or` query method, similar to the existing > `where.not`. This new method would take params in the same way `where` > does, but instead of using AND as a keyword to join the predicates, it > would use OR. The query above would be built as follows: > > Author.where.or(first_name: 'John', last_name: 'Smith') > > I’m not sure if I’m missing something fundamental that makes this feature > difficult to implement. I’ve actually implemented a working version and I’d > be happy to push a PR if the feedback is positive. > > Besides the technical challenges that may arise, do you think it’s a > useful feature? > > Thanks! > > -- > 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+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/rubyonrails-core/125f930d-73ef-4dab-b353-77a8f2e4280a%40googlegroups.com > <https://groups.google.com/d/msgid/rubyonrails-core/125f930d-73ef-4dab-b353-77a8f2e4280a%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-core/CAFsKq7ZKcw7jt1gxbiPdbUmwkVKPJqNi5%3DXpdpXau7ROKF-6dQ%40mail.gmail.com.