Hi guys, I''want to introduce this discussion (I''m looking for similar here, but don''t found it) Actually the scopes chainity is glued with "AND" operator. Some times we need to chain the same scope implemented method using both "OR" or cases with "AND" operators. But It''s not possible because chainity does only with "AND" operator. If you need "OR" conditions you need to re-implement explicit method to do it. In the interests of DRY, *what you think to pass a "chainity_operator" param in chain scopes??* by default can be set to "AND", but can be changed for an "OR" if need. Then we can reuse the sames scopes on differents combinations. Or may a chainity_operator method that can be chained with scoped where methods? I''m not sure if possible or if it break any AR-AREL architecture. Best -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-core/-/Tx8fWmHOCmIJ. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
Hi guys, I''want to introduce this discussion (I''m looking for similar here, but don''t found it) Actually the scopes chainity is glued with "AND" operator. Some times we need to chain the same scope implemented method using both "OR" or cases with "AND" operators. But It''s not possible because chainity does only with "AND" operator. If you need "OR" conditions you need to re-implement explicit method to do it. In the interests of DRY, *what you think to pass a "chainity_operator" param in chain scopes??* by default can be set to "AND", but can be changed for an "OR" if need. Then we can reuse the sames scopes on differents combinations. Or may a chainity_operator method that can be chained with scoped where methods? I''m not sure if possible or if it break any AR-AREL architecture. Best -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-core/-/LFQWTRHdM8EJ. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
Jonathan Lozinski
2012-Jun-21 15:27 UTC
Re: Scopes with OR and AND optional chainity discussion
We have wanted similar, and resorted to getting where''s out of arel. I thought about the following syntax: MyModel.somescope.or(something_which_is_a_scope_chain_too) Sent from my iPhone On 21 Jun 2012, at 15:57, daniel2d2art <daniel2d2art@gmail.com> wrote: Hi guys, I''want to introduce this discussion (I''m looking for similar here, but don''t found it) Actually the scopes chainity is glued with "AND" operator. Some times we need to chain the same scope implemented method using both "OR" or cases with "AND" operators. But It''s not possible because chainity does only with "AND" operator. If you need "OR" conditions you need to re-implement explicit method to do it. In the interests of DRY, *what you think to pass a "chainity_operator" param in chain scopes??* by default can be set to "AND", but can be changed for an "OR" if need. Then we can reuse the sames scopes on differents combinations. Or may a chainity_operator method that can be chained with scoped where methods? I''m not sure if possible or if it break any AR-AREL architecture. Best -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-core/-/LFQWTRHdM8EJ. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
daniel2d2art
2012-Jun-21 17:35 UTC
Re: Scopes with OR and AND optional chainity discussion
Yes I think some chainity_operator method like you say, can works ok too. On Thursday, June 21, 2012 5:27:51 PM UTC+2, mrloz wrote:> > We have wanted similar, and resorted to getting where''s out of arel. > > I thought about the following syntax: > > > MyModel.somescope.or(something_which_is_a_scope_chain_too) > > > > Sent from my iPhone > > On 21 Jun 2012, at 15:57, daniel2d2art <daniel2d2art@gmail.com> wrote: > > Hi guys, I''want to introduce this discussion (I''m looking for similar > here, but don''t found it) > > Actually the scopes chainity is glued with "AND" operator. > Some times we need to chain the same scope implemented method using both > "OR" or cases with "AND" operators. But It''s not possible because chainity > does only with "AND" operator. If you need "OR" conditions you need to > re-implement explicit method to do it. > In the interests of DRY, *what you think to pass a "chainity_operator" > param in chain scopes??* by default can be set to "AND", but can be > changed for an "OR" if need. Then we can reuse the sames scopes on > differents combinations. > Or may a chainity_operator method that can be chained with scoped where > methods? > I''m not sure if possible or if it break any AR-AREL architecture. > > Best > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Core" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/rubyonrails-core/-/LFQWTRHdM8EJ. > To post to this group, send email to rubyonrails-core@googlegroups.com. > To unsubscribe from this group, send email to > rubyonrails-core+unsubscribe@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/rubyonrails-core?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-core/-/vMihSC-FuxgJ. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
Jonathan Lozinski
2012-Jun-21 21:27 UTC
Re: Scopes with OR and AND optional chainity discussion
I have raised a pull request which gets this started, though there''s feedback required for sure: https://github.com/rails/rails/pull/6817 On 21 June 2012 18:35, daniel2d2art <daniel2d2art@gmail.com> wrote:> Yes I think some chainity_operator method like you say, can works ok too. > > > On Thursday, June 21, 2012 5:27:51 PM UTC+2, mrloz wrote: >> >> We have wanted similar, and resorted to getting where''s out of arel. >> >> I thought about the following syntax: >> >> >> MyModel.somescope.or(**something_which_is_a_scope_**chain_too) >> >> >> >> Sent from my iPhone >> >> On 21 Jun 2012, at 15:57, daniel2d2art <daniel2d2art@gmail.com> wrote: >> >> Hi guys, I''want to introduce this discussion (I''m looking for similar >> here, but don''t found it) >> >> Actually the scopes chainity is glued with "AND" operator. >> Some times we need to chain the same scope implemented method using both >> "OR" or cases with "AND" operators. But It''s not possible because chainity >> does only with "AND" operator. If you need "OR" conditions you need to >> re-implement explicit method to do it. >> In the interests of DRY, *what you think to pass a "chainity_operator" >> param in chain scopes??* by default can be set to "AND", but can be >> changed for an "OR" if need. Then we can reuse the sames scopes on >> differents combinations. >> Or may a chainity_operator method that can be chained with scoped where >> methods? >> I''m not sure if possible or if it break any AR-AREL architecture. >> >> Best >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Ruby on Rails: Core" group. >> To view this discussion on the web visit https://groups.google.com/d/** >> msg/rubyonrails-core/-/**LFQWTRHdM8EJ<https://groups.google.com/d/msg/rubyonrails-core/-/LFQWTRHdM8EJ> >> . >> To post to this group, send email to rubyonrails-core@googlegroups.**com<rubyonrails-core@googlegroups.com> >> . >> To unsubscribe from this group, send email to >> rubyonrails-core+unsubscribe@**googlegroups.com<rubyonrails-core+unsubscribe@googlegroups.com> >> . >> For more options, visit this group at http://groups.google.com/** >> group/rubyonrails-core?hl=en<http://groups.google.com/group/rubyonrails-core?hl=en> >> . >> >> -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Core" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/rubyonrails-core/-/vMihSC-FuxgJ. > > To post to this group, send email to rubyonrails-core@googlegroups.com. > To unsubscribe from this group, send email to > rubyonrails-core+unsubscribe@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/rubyonrails-core?hl=en. >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
Emile Cantin
2012-Jun-21 21:42 UTC
Re: Scopes with OR and AND optional chainity discussion
This would be a very good idea; I proposed this change on GitHub a few months ago, but it didn''t get a lot of traction: https://github.com/rails/rails/issues/5545. I think chaining scopes with OR would be a very common use case for a search functionality. For example, you could allow users to search for something matching all parameters (chaining with AND) or only one of them (chaining with OR). I think it would be a relatively simple change to implement, but I''m not at all familiar with Rails'' source code, so I don''t really know what I''m talking about here. Anyway, consider this +1 from me. Emile Le 2012-06-21 à 09:48, daniel2d2art a écrit :> Hi guys, I''want to introduce this discussion (I''m looking for similar here, but don''t found it) > > Actually the scopes chainity is glued with "AND" operator. > Some times we need to chain the same scope implemented method using both "OR" or cases with "AND" operators. But It''s not possible because chainity does only with "AND" operator. If you need "OR" conditions you need to re-implement explicit method to do it. > In the interests of DRY, what you think to pass a "chainity_operator" param in chain scopes?? by default can be set to "AND", but can be changed for an "OR" if need. Then we can reuse the sames scopes on differents combinations. > Or may a chainity_operator method that can be chained with scoped where methods? > I''m not sure if possible or if it break any AR-AREL architecture. > > Best > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. > To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-core/-/Tx8fWmHOCmIJ. > To post to this group, send email to rubyonrails-core@googlegroups.com. > To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
Daniel Vázquez
2012-Jun-22 00:13 UTC
Re: Scopes with OR and AND optional chainity discussion
Wow yep! I''hope this prosperes ... I''m not sure next step for consolidation on RoR version. Thanks Loz 2012/6/21 Jonathan Lozinski <jonathan.lozinski@gmail.com>> I have raised a pull request which gets this started, though there''s > feedback required for sure: > > https://github.com/rails/rails/pull/6817 > > > On 21 June 2012 18:35, daniel2d2art <daniel2d2art@gmail.com> wrote: > >> Yes I think some chainity_operator method like you say, can works ok too. >> >> >> On Thursday, June 21, 2012 5:27:51 PM UTC+2, mrloz wrote: >>> >>> We have wanted similar, and resorted to getting where''s out of arel. >>> >>> I thought about the following syntax: >>> >>> >>> MyModel.somescope.or(**something_which_is_a_scope_**chain_too) >>> >>> >>> >>> Sent from my iPhone >>> >>> On 21 Jun 2012, at 15:57, daniel2d2art <daniel2d2art@gmail.com> wrote: >>> >>> Hi guys, I''want to introduce this discussion (I''m looking for similar >>> here, but don''t found it) >>> >>> Actually the scopes chainity is glued with "AND" operator. >>> Some times we need to chain the same scope implemented method using both >>> "OR" or cases with "AND" operators. But It''s not possible because chainity >>> does only with "AND" operator. If you need "OR" conditions you need to >>> re-implement explicit method to do it. >>> In the interests of DRY, *what you think to pass a "chainity_operator" >>> param in chain scopes??* by default can be set to "AND", but can be >>> changed for an "OR" if need. Then we can reuse the sames scopes on >>> differents combinations. >>> Or may a chainity_operator method that can be chained with scoped where >>> methods? >>> I''m not sure if possible or if it break any AR-AREL architecture. >>> >>> Best >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Ruby on Rails: Core" group. >>> To view this discussion on the web visit https://groups.google.com/d/** >>> msg/rubyonrails-core/-/**LFQWTRHdM8EJ<https://groups.google.com/d/msg/rubyonrails-core/-/LFQWTRHdM8EJ> >>> . >>> To post to this group, send email to rubyonrails-core@googlegroups.**com<rubyonrails-core@googlegroups.com> >>> . >>> To unsubscribe from this group, send email to >>> rubyonrails-core+unsubscribe@**googlegroups.com<rubyonrails-core+unsubscribe@googlegroups.com> >>> . >>> For more options, visit this group at http://groups.google.com/** >>> group/rubyonrails-core?hl=en<http://groups.google.com/group/rubyonrails-core?hl=en> >>> . >>> >>> -- >> You received this message because you are subscribed to the Google Groups >> "Ruby on Rails: Core" group. >> To view this discussion on the web visit >> https://groups.google.com/d/msg/rubyonrails-core/-/vMihSC-FuxgJ. >> >> To post to this group, send email to rubyonrails-core@googlegroups.com. >> To unsubscribe from this group, send email to >> rubyonrails-core+unsubscribe@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/rubyonrails-core?hl=en. >> > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Core" group. > To post to this group, send email to rubyonrails-core@googlegroups.com. > To unsubscribe from this group, send email to > rubyonrails-core+unsubscribe@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/rubyonrails-core?hl=en. >-- Daniel Vázquez SICONET (A Bull Group Company) Torre Agbar. Avda. Diagonal, 211 - planta 23 08018 - Barcelona telf: + 34 93 2272727 (Ext. 2952) fax: + 34 93 2272728 www.bull.es - www.siconet.es daniel.vazquez@bull.es -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
Andrew Kaspick
2012-Jun-22 02:05 UTC
Re: Scopes with OR and AND optional chainity discussion
Maybe I''ve missed it, but how do you define precedence between the usual AND''s and now OR''s? Chaining a bunch of AND''s will always results in the same result, but add OR to the mix and now you''re complicating things unless you''re a lot more explicit with the conditions. On Thu, Jun 21, 2012 at 7:13 PM, Daniel Vázquez <daniel2d2art@gmail.com> wrote:> Wow yep! I''hope this prosperes ... I''m not sure next step for consolidation > on RoR version. > Thanks Loz > > > 2012/6/21 Jonathan Lozinski <jonathan.lozinski@gmail.com> >> >> I have raised a pull request which gets this started, though there''s >> feedback required for sure: >> >> https://github.com/rails/rails/pull/6817 >> >> >> On 21 June 2012 18:35, daniel2d2art <daniel2d2art@gmail.com> wrote: >>> >>> Yes I think some chainity_operator method like you say, can works ok too. >>> >>> >>> On Thursday, June 21, 2012 5:27:51 PM UTC+2, mrloz wrote: >>>> >>>> We have wanted similar, and resorted to getting where''s out of arel. >>>> >>>> I thought about the following syntax: >>>> >>>> >>>> MyModel.somescope.or(something_which_is_a_scope_chain_too) >>>> >>>> >>>> >>>> Sent from my iPhone >>>> >>>> On 21 Jun 2012, at 15:57, daniel2d2art <daniel2d2art@gmail.com> wrote: >>>> >>>> Hi guys, I''want to introduce this discussion (I''m looking for similar >>>> here, but don''t found it) >>>> >>>> Actually the scopes chainity is glued with "AND" operator. >>>> Some times we need to chain the same scope implemented method using both >>>> "OR" or cases with "AND" operators. But It''s not possible because chainity >>>> does only with "AND" operator. If you need "OR" conditions you need to >>>> re-implement explicit method to do it. >>>> In the interests of DRY, what you think to pass a "chainity_operator" >>>> param in chain scopes?? by default can be set to "AND", but can be changed >>>> for an "OR" if need. Then we can reuse the sames scopes on differents >>>> combinations. >>>> Or may a chainity_operator method that can be chained with scoped where >>>> methods? >>>> I''m not sure if possible or if it break any AR-AREL architecture. >>>> >>>> Best >>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "Ruby on Rails: Core" group. >>>> To view this discussion on the web visit >>>> https://groups.google.com/d/msg/rubyonrails-core/-/LFQWTRHdM8EJ. >>>> To post to this group, send email to rubyonrails-core@googlegroups.com. >>>> To unsubscribe from this group, send email to >>>> rubyonrails-core+unsubscribe@googlegroups.com. >>>> For more options, visit this group at >>>> http://groups.google.com/group/rubyonrails-core?hl=en. >>> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "Ruby on Rails: Core" group. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msg/rubyonrails-core/-/vMihSC-FuxgJ. >>> >>> To post to this group, send email to rubyonrails-core@googlegroups.com. >>> To unsubscribe from this group, send email to >>> rubyonrails-core+unsubscribe@googlegroups.com. >>> For more options, visit this group at >>> http://groups.google.com/group/rubyonrails-core?hl=en. >> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Ruby on Rails: Core" group. >> To post to this group, send email to rubyonrails-core@googlegroups.com. >> To unsubscribe from this group, send email to >> rubyonrails-core+unsubscribe@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/rubyonrails-core?hl=en. > > > > > -- > Daniel Vázquez > SICONET (A Bull Group Company) > Torre Agbar. Avda. Diagonal, 211 - planta 23 > 08018 - Barcelona > telf: + 34 93 2272727 (Ext. 2952) > fax: + 34 93 2272728 > www.bull.es - www.siconet.es > daniel.vazquez@bull.es > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Core" group. > To post to this group, send email to rubyonrails-core@googlegroups.com. > To unsubscribe from this group, send email to > rubyonrails-core+unsubscribe@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/rubyonrails-core?hl=en.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
daniel2d2art
2012-Jun-22 16:05 UTC
Re: Scopes with OR and AND optional chainity discussion
We''re following to using disjunction on two or more chained scopes. This scopes can continue use custom logical conditions. Normal would be to use parentheses between on query. In pro of DRY some cases we need use scopes conected as AND but in another cases we need to use OR connections. Rails only do scope chain with AND. Some times you need to rewritte a full functionality of one or more scoper only for use OR connections. On 22 jun, 04:05, Andrew Kaspick <akasp...@gmail.com> wrote:> Maybe I''ve missed it, but how do you define precedence between the > usual AND''s and now OR''s? Chaining a bunch of AND''s will always > results in the same result, but add OR to the mix and now you''re > complicating things unless you''re a lot more explicit with the > conditions. > > > > > > > > On Thu, Jun 21, 2012 at 7:13 PM, Daniel Vázquez <daniel2d2...@gmail.com> wrote: > > Wow yep! I''hope this prosperes ... I''m not sure next step for consolidation > > on RoR version. > > Thanks Loz > > > 2012/6/21 Jonathan Lozinski <jonathan.lozin...@gmail.com> > > >> I have raised a pull request which gets this started, though there''s > >> feedback required for sure: > > >>https://github.com/rails/rails/pull/6817 > > >> On 21 June 2012 18:35, daniel2d2art <daniel2d2...@gmail.com> wrote: > > >>> Yes I think some chainity_operator method like you say, can works ok too. > > >>> On Thursday, June 21, 2012 5:27:51 PM UTC+2, mrloz wrote: > > >>>> We have wanted similar, and resorted to getting where''s out of arel. > > >>>> I thought about the following syntax: > > >>>> MyModel.somescope.or(something_which_is_a_scope_chain_too) > > >>>> Sent from my iPhone > > >>>> On 21 Jun 2012, at 15:57, daniel2d2art <daniel2d2...@gmail.com> wrote: > > >>>> Hi guys, I''want to introduce this discussion (I''m looking for similar > >>>> here, but don''t found it) > > >>>> Actually the scopes chainity is glued with "AND" operator. > >>>> Some times we need to chain the same scope implemented method using both > >>>> "OR" or cases with "AND" operators. But It''s not possible because chainity > >>>> does only with "AND" operator. If you need "OR" conditions you need to > >>>> re-implement explicit method to do it. > >>>> In the interests of DRY, what you think to pass a "chainity_operator" > >>>> param in chain scopes?? by default can be set to "AND", but can be changed > >>>> for an "OR" if need. Then we can reuse the sames scopes on differents > >>>> combinations. > >>>> Or may a chainity_operator method that can be chained with scoped where > >>>> methods? > >>>> I''m not sure if possible or if it break any AR-AREL architecture. > > >>>> Best > > >>>> -- > >>>> You received this message because you are subscribed to the Google > >>>> Groups "Ruby on Rails: Core" group. > >>>> To view this discussion on the web visit > >>>>https://groups.google.com/d/msg/rubyonrails-core/-/LFQWTRHdM8EJ. > >>>> To post to this group, send email to rubyonrails-core@googlegroups.com. > >>>> To unsubscribe from this group, send email to > >>>> rubyonrails-core+unsubscribe@googlegroups.com. > >>>> For more options, visit this group at > >>>>http://groups.google.com/group/rubyonrails-core?hl=en. > > >>> -- > >>> You received this message because you are subscribed to the Google Groups > >>> "Ruby on Rails: Core" group. > >>> To view this discussion on the web visit > >>>https://groups.google.com/d/msg/rubyonrails-core/-/vMihSC-FuxgJ. > > >>> To post to this group, send email to rubyonrails-core@googlegroups.com. > >>> To unsubscribe from this group, send email to > >>> rubyonrails-core+unsubscribe@googlegroups.com. > >>> For more options, visit this group at > >>>http://groups.google.com/group/rubyonrails-core?hl=en. > > >> -- > >> You received this message because you are subscribed to the Google Groups > >> "Ruby on Rails: Core" group. > >> To post to this group, send email to rubyonrails-core@googlegroups.com. > >> To unsubscribe from this group, send email to > >> rubyonrails-core+unsubscribe@googlegroups.com. > >> For more options, visit this group at > >>http://groups.google.com/group/rubyonrails-core?hl=en. > > > -- > > Daniel Vázquez > > SICONET (A Bull Group Company) > > Torre Agbar. Avda. Diagonal, 211 - planta 23 > > 08018 - Barcelona > > telf: + 34 93 2272727 (Ext. 2952) > > fax: + 34 93 2272728 > >www.bull.es-www.siconet.es > > daniel.vazq...@bull.es > > > -- > > You received this message because you are subscribed to the Google Groups > > "Ruby on Rails: Core" group. > > To post to this group, send email to rubyonrails-core@googlegroups.com. > > To unsubscribe from this group, send email to > > rubyonrails-core+unsubscribe@googlegroups.com. > > For more options, visit this group at > >http://groups.google.com/group/rubyonrails-core?hl=en.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
daniel2d2art
2012-Jun-22 16:07 UTC
Re: Scopes with OR and AND optional chainity discussion
Wow yep! I''hope this prosperes ... I''m not sure next step for consolidation on RoR version. Thanks Loz On 21 jun, 23:27, Jonathan Lozinski <jonathan.lozin...@gmail.com> wrote:> I have raised a pull request which gets this started, though there''s > feedback required for sure: > > https://github.com/rails/rails/pull/6817 > > On 21 June 2012 18:35, daniel2d2art <daniel2d2...@gmail.com> wrote: > > > > > > > > > Yes I think some chainity_operator method like you say, can works ok too. > > > On Thursday, June 21, 2012 5:27:51 PM UTC+2, mrloz wrote: > > >> We have wanted similar, and resorted to getting where''s out of arel. > > >> I thought about the following syntax: > > >> MyModel.somescope.or(**something_which_is_a_scope_**chain_too) > > >> Sent from my iPhone > > >> On 21 Jun 2012, at 15:57, daniel2d2art <daniel2d2...@gmail.com> wrote: > > >> Hi guys, I''want to introduce this discussion (I''m looking for similar > >> here, but don''t found it) > > >> Actually the scopes chainity is glued with "AND" operator. > >> Some times we need to chain the same scope implemented method using both > >> "OR" or cases with "AND" operators. But It''s not possible because chainity > >> does only with "AND" operator. If you need "OR" conditions you need to > >> re-implement explicit method to do it. > >> In the interests of DRY, *what you think to pass a "chainity_operator" > >> param in chain scopes??* by default can be set to "AND", but can be > >> changed for an "OR" if need. Then we can reuse the sames scopes on > >> differents combinations. > >> Or may a chainity_operator method that can be chained with scoped where > >> methods? > >> I''m not sure if possible or if it break any AR-AREL architecture. > > >> Best > > >> -- > >> You received this message because you are subscribed to the Google Groups > >> "Ruby on Rails: Core" group. > >> To view this discussion on the web visithttps://groups.google.com/d/** > >> msg/rubyonrails-core/-/**LFQWTRHdM8EJ<https://groups.google.com/d/msg/rubyonrails-core/-/LFQWTRHdM8EJ> > >> . > >> To post to this group, send email to rubyonrails-core@googlegroups.**com<rubyonrails-core@googlegroups.com> > >> . > >> To unsubscribe from this group, send email to > >> rubyonrails-core+unsubscribe@**googlegroups.com<rubyonrails-core+unsubscrib e@googlegroups.com> > >> . > >> For more options, visit this group athttp://groups.google.com/** > >> group/rubyonrails-core?hl=en<http://groups.google.com/group/rubyonrails-core?hl=en> > >> . > > >> -- > > You received this message because you are subscribed to the Google Groups > > "Ruby on Rails: Core" group. > > To view this discussion on the web visit > >https://groups.google.com/d/msg/rubyonrails-core/-/vMihSC-FuxgJ. > > > To post to this group, send email to rubyonrails-core@googlegroups.com. > > To unsubscribe from this group, send email to > > rubyonrails-core+unsubscribe@googlegroups.com. > > For more options, visit this group at > >http://groups.google.com/group/rubyonrails-core?hl=en.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
Jonathan Lozinski
2012-Jun-22 16:20 UTC
Re: Re: Scopes with OR and AND optional chainity discussion
I believe that the arel implementation leads to brackets around left and right sides of the or. This can be checked by using my branch and doing .to_sql on any scope chain produced. Sent from my iPhone On 22 Jun 2012, at 17:05, daniel2d2art <daniel2d2art@gmail.com> wrote:> We''re following to using disjunction on two or more chained scopes. > This scopes can continue use custom logical conditions. Normal would > be to use parentheses between on query. > In pro of DRY some cases we need use scopes conected as AND but in > another cases we need to use OR connections. Rails only do scope chain > with AND. Some times you need to rewritte a full functionality of one > or more scoper only for use OR connections. > > > On 22 jun, 04:05, Andrew Kaspick <akasp...@gmail.com> wrote: >> Maybe I''ve missed it, but how do you define precedence between the >> usual AND''s and now OR''s? Chaining a bunch of AND''s will always >> results in the same result, but add OR to the mix and now you''re >> complicating things unless you''re a lot more explicit with the >> conditions. >> >> >> >> >> >> >> >> On Thu, Jun 21, 2012 at 7:13 PM, Daniel Vázquez <daniel2d2...@gmail.com> wrote: >>> Wow yep! I''hope this prosperes ... I''m not sure next step for consolidation >>> on RoR version. >>> Thanks Loz >> >>> 2012/6/21 Jonathan Lozinski <jonathan.lozin...@gmail.com> >> >>>> I have raised a pull request which gets this started, though there''s >>>> feedback required for sure: >> >>>> https://github.com/rails/rails/pull/6817 >> >>>> On 21 June 2012 18:35, daniel2d2art <daniel2d2...@gmail.com> wrote: >> >>>>> Yes I think some chainity_operator method like you say, can works ok too. >> >>>>> On Thursday, June 21, 2012 5:27:51 PM UTC+2, mrloz wrote: >> >>>>>> We have wanted similar, and resorted to getting where''s out of arel. >> >>>>>> I thought about the following syntax: >> >>>>>> MyModel.somescope.or(something_which_is_a_scope_chain_too) >> >>>>>> Sent from my iPhone >> >>>>>> On 21 Jun 2012, at 15:57, daniel2d2art <daniel2d2...@gmail.com> wrote: >> >>>>>> Hi guys, I''want to introduce this discussion (I''m looking for similar >>>>>> here, but don''t found it) >> >>>>>> Actually the scopes chainity is glued with "AND" operator. >>>>>> Some times we need to chain the same scope implemented method using both >>>>>> "OR" or cases with "AND" operators. But It''s not possible because chainity >>>>>> does only with "AND" operator. If you need "OR" conditions you need to >>>>>> re-implement explicit method to do it. >>>>>> In the interests of DRY, what you think to pass a "chainity_operator" >>>>>> param in chain scopes?? by default can be set to "AND", but can be changed >>>>>> for an "OR" if need. Then we can reuse the sames scopes on differents >>>>>> combinations. >>>>>> Or may a chainity_operator method that can be chained with scoped where >>>>>> methods? >>>>>> I''m not sure if possible or if it break any AR-AREL architecture. >> >>>>>> Best >> >>>>>> -- >>>>>> You received this message because you are subscribed to the Google >>>>>> Groups "Ruby on Rails: Core" group. >>>>>> To view this discussion on the web visit >>>>>> https://groups.google.com/d/msg/rubyonrails-core/-/LFQWTRHdM8EJ. >>>>>> To post to this group, send email to rubyonrails-core@googlegroups.com. >>>>>> To unsubscribe from this group, send email to >>>>>> rubyonrails-core+unsubscribe@googlegroups.com. >>>>>> For more options, visit this group at >>>>>> http://groups.google.com/group/rubyonrails-core?hl=en. >> >>>>> -- >>>>> You received this message because you are subscribed to the Google Groups >>>>> "Ruby on Rails: Core" group. >>>>> To view this discussion on the web visit >>>>> https://groups.google.com/d/msg/rubyonrails-core/-/vMihSC-FuxgJ. >> >>>>> To post to this group, send email to rubyonrails-core@googlegroups.com. >>>>> To unsubscribe from this group, send email to >>>>> rubyonrails-core+unsubscribe@googlegroups.com. >>>>> For more options, visit this group at >>>>> http://groups.google.com/group/rubyonrails-core?hl=en. >> >>>> -- >>>> You received this message because you are subscribed to the Google Groups >>>> "Ruby on Rails: Core" group. >>>> To post to this group, send email to rubyonrails-core@googlegroups.com. >>>> To unsubscribe from this group, send email to >>>> rubyonrails-core+unsubscribe@googlegroups.com. >>>> For more options, visit this group at >>>> http://groups.google.com/group/rubyonrails-core?hl=en. >> >>> -- >>> Daniel Vázquez >>> SICONET (A Bull Group Company) >>> Torre Agbar. Avda. Diagonal, 211 - planta 23 >>> 08018 - Barcelona >>> telf: + 34 93 2272727 (Ext. 2952) >>> fax: + 34 93 2272728 >>> www.bull.es-www.siconet.es >>> daniel.vazq...@bull.es >> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "Ruby on Rails: Core" group. >>> To post to this group, send email to rubyonrails-core@googlegroups.com. >>> To unsubscribe from this group, send email to >>> rubyonrails-core+unsubscribe@googlegroups.com. >>> For more options, visit this group at >>> http://groups.google.com/group/rubyonrails-core?hl=en. > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. > To post to this group, send email to rubyonrails-core@googlegroups.com. > To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en. >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
daniel2d2art
2012-Jun-22 16:28 UTC
Re: Scopes with OR and AND optional chainity discussion
Yes, I think so too On 22 jun, 18:20, Jonathan Lozinski <jonathan.lozin...@gmail.com> wrote:> I believe that the arel implementation leads to brackets around left > and right sides of the or. This can be checked by using my branch and > doing .to_sql on any scope chain produced. > > Sent from my iPhone > > On 22 Jun 2012, at 17:05, daniel2d2art <daniel2d2...@gmail.com> wrote: > > > > > > > > > We''re following to using disjunction on two or more chained scopes. > > This scopes can continue use custom logical conditions. Normal would > > be to use parentheses between on query. > > In pro of DRY some cases we need use scopes conected as AND but in > > another cases we need to use OR connections. Rails only do scope chain > > with AND. Some times you need to rewritte a full functionality of one > > or more scoper only for use OR connections. > > > On 22 jun, 04:05, Andrew Kaspick <akasp...@gmail.com> wrote: > >> Maybe I''ve missed it, but how do you define precedence between the > >> usual AND''s and now OR''s? Chaining a bunch of AND''s will always > >> results in the same result, but add OR to the mix and now you''re > >> complicating things unless you''re a lot more explicit with the > >> conditions. > > >> On Thu, Jun 21, 2012 at 7:13 PM, Daniel Vázquez <daniel2d2...@gmail.com> wrote: > >>> Wow yep! I''hope this prosperes ... I''m not sure next step for consolidation > >>> on RoR version. > >>> Thanks Loz > > >>> 2012/6/21 Jonathan Lozinski <jonathan.lozin...@gmail.com> > > >>>> I have raised a pull request which gets this started, though there''s > >>>> feedback required for sure: > > >>>>https://github.com/rails/rails/pull/6817 > > >>>> On 21 June 2012 18:35, daniel2d2art <daniel2d2...@gmail.com> wrote: > > >>>>> Yes I think some chainity_operator method like you say, can works ok too. > > >>>>> On Thursday, June 21, 2012 5:27:51 PM UTC+2, mrloz wrote: > > >>>>>> We have wanted similar, and resorted to getting where''s out of arel. > > >>>>>> I thought about the following syntax: > > >>>>>> MyModel.somescope.or(something_which_is_a_scope_chain_too) > > >>>>>> Sent from my iPhone > > >>>>>> On 21 Jun 2012, at 15:57, daniel2d2art <daniel2d2...@gmail.com> wrote: > > >>>>>> Hi guys, I''want to introduce this discussion (I''m looking for similar > >>>>>> here, but don''t found it) > > >>>>>> Actually the scopes chainity is glued with "AND" operator. > >>>>>> Some times we need to chain the same scope implemented method using both > >>>>>> "OR" or cases with "AND" operators. But It''s not possible because chainity > >>>>>> does only with "AND" operator. If you need "OR" conditions you need to > >>>>>> re-implement explicit method to do it. > >>>>>> In the interests of DRY, what you think to pass a "chainity_operator" > >>>>>> param in chain scopes?? by default can be set to "AND", but can be changed > >>>>>> for an "OR" if need. Then we can reuse the sames scopes on differents > >>>>>> combinations. > >>>>>> Or may a chainity_operator method that can be chained with scoped where > >>>>>> methods? > >>>>>> I''m not sure if possible or if it break any AR-AREL architecture. > > >>>>>> Best > > >>>>>> -- > >>>>>> You received this message because you are subscribed to the Google > >>>>>> Groups "Ruby on Rails: Core" group. > >>>>>> To view this discussion on the web visit > >>>>>>https://groups.google.com/d/msg/rubyonrails-core/-/LFQWTRHdM8EJ. > >>>>>> To post to this group, send email to rubyonrails-core@googlegroups.com. > >>>>>> To unsubscribe from this group, send email to > >>>>>> rubyonrails-core+unsubscribe@googlegroups.com. > >>>>>> For more options, visit this group at > >>>>>>http://groups.google.com/group/rubyonrails-core?hl=en. > > >>>>> -- > >>>>> You received this message because you are subscribed to the Google Groups > >>>>> "Ruby on Rails: Core" group. > >>>>> To view this discussion on the web visit > >>>>>https://groups.google.com/d/msg/rubyonrails-core/-/vMihSC-FuxgJ. > > >>>>> To post to this group, send email to rubyonrails-core@googlegroups.com. > >>>>> To unsubscribe from this group, send email to > >>>>> rubyonrails-core+unsubscribe@googlegroups.com. > >>>>> For more options, visit this group at > >>>>>http://groups.google.com/group/rubyonrails-core?hl=en. > > >>>> -- > >>>> You received this message because you are subscribed to the Google Groups > >>>> "Ruby on Rails: Core" group. > >>>> To post to this group, send email to rubyonrails-core@googlegroups.com. > >>>> To unsubscribe from this group, send email to > >>>> rubyonrails-core+unsubscribe@googlegroups.com. > >>>> For more options, visit this group at > >>>>http://groups.google.com/group/rubyonrails-core?hl=en. > > >>> -- > >>> Daniel Vázquez > >>> SICONET (A Bull Group Company) > >>> Torre Agbar. Avda. Diagonal, 211 - planta 23 > >>> 08018 - Barcelona > >>> telf: + 34 93 2272727 (Ext. 2952) > >>> fax: + 34 93 2272728 > >>>www.bull.es-www.siconet.es > >>> daniel.vazq...@bull.es > > >>> -- > >>> You received this message because you are subscribed to the Google Groups > >>> "Ruby on Rails: Core" group. > >>> To post to this group, send email to rubyonrails-core@googlegroups.com. > >>> To unsubscribe from this group, send email to > >>> rubyonrails-core+unsubscribe@googlegroups.com. > >>> For more options, visit this group at > >>>http://groups.google.com/group/rubyonrails-core?hl=en. > > > -- > > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. > > To post to this group, send email to rubyonrails-core@googlegroups.com. > > To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. > > For more options, visit this group athttp://groups.google.com/group/rubyonrails-core?hl=en.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.