Hi all, I''ve been playing around with Arel this week (actually outside of Rails) and found an issue with the clone implementation. I''ve added a patch and a testcase here: https://github.com/codders/arel/commit/660f706491ac012cb133554cffeaa6b9ae6046e9 and made a pull request against the rails/arel repo. I''ve also been playing around with support for ordering on Expressions (e.g. ORDER BY COUNT(DISTINCT blah) DESC): https://github.com/codders/arel/commit/10a9fe64b87579592307ffbc3b18bf69c5bcf15c and even more experimentally, with adding placeholders to allow a query to be evaluated multiple times in different dynamic contexts: https://github.com/codders/arel/commit/4b9ae3de9edee084303e6f29145b0e4ce5e04481 So... a) How can I get my bugfix merged - who should I talk to, what else do you need? b) What''s the best forum for discussing / getting involved in Arel development. Thanks, Arthur -- 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.
Update - That got merged (thanks!). So only the one question. Arthur On 18/04/11 14:37, Arthur Taylor wrote:> Hi all, > > I''ve been playing around with Arel this week (actually outside of > Rails) and found an issue with the clone implementation. I''ve added a > patch and a testcase here: > > https://github.com/codders/arel/commit/660f706491ac012cb133554cffeaa6b9ae6046e9 > > > and made a pull request against the rails/arel repo. > > I''ve also been playing around with support for ordering on Expressions > (e.g. ORDER BY COUNT(DISTINCT blah) DESC): > > https://github.com/codders/arel/commit/10a9fe64b87579592307ffbc3b18bf69c5bcf15c > > > and even more experimentally, with adding placeholders to allow a > query to be evaluated multiple times in different dynamic contexts: > > https://github.com/codders/arel/commit/4b9ae3de9edee084303e6f29145b0e4ce5e04481 > > > So... a) How can I get my bugfix merged - who should I talk to, what > else do you need? > b) What''s the best forum for discussing / getting involved in Arel > development. > > Thanks, > > Arthur >-- 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.
On Tue, Apr 19, 2011 at 09:41:21AM +0200, Arthur Taylor wrote:> Update - That got merged (thanks!). So only the one question. > > Arthur > > On 18/04/11 14:37, Arthur Taylor wrote: > >Hi all, > > > >I''ve been playing around with Arel this week (actually outside of > >Rails) and found an issue with the clone implementation. I''ve > >added a patch and a testcase here: > > > >https://github.com/codders/arel/commit/660f706491ac012cb133554cffeaa6b9ae6046e9 > > > > > >and made a pull request against the rails/arel repo. > > > >I''ve also been playing around with support for ordering on > >Expressions (e.g. ORDER BY COUNT(DISTINCT blah) DESC): > > > >https://github.com/codders/arel/commit/10a9fe64b87579592307ffbc3b18bf69c5bcf15c > > > > > >and even more experimentally, with adding placeholders to allow a > >query to be evaluated multiple times in different dynamic > >contexts: > > > >https://github.com/codders/arel/commit/4b9ae3de9edee084303e6f29145b0e4ce5e04481There are no tests for this, so I''m not sure what it actually does. Is "placeholder" in the SQL BNF?> >So... a) How can I get my bugfix merged - who should I talk to, > >what else do you need? > >b) What''s the best forum for discussing / getting involved in Arel > >development.For now, we should discuss here. I''ll open a mailing list soon, and we can move there eventually. :-) -- Aaron Patterson http://tenderlovemaking.com/
Tests. Yes :)>>> and even more experimentally, with adding placeholders to allow a >>> query to be evaluated multiple times in different dynamic >>> contexts: >>> >>> https://github.com/codders/arel/commit/4b9ae3de9edee084303e6f29145b0e4ce5e04481 > There are no tests for this, so I''m not sure what it actually does. > Is "placeholder" in the SQL BNF?No, I don''t imagine so. The idea with the placeholders is that you could have one query which serializes differently to SQL (or through any of the visitors) depending on the dynamic value of the placeholders. The effect I want (and am using in my local repo) is not to have to define the values of all the query terms at query build time: @placeholders = { :username => "bob" } query = @users.project(@users[:id]).where(@users[:name].eq(Arel::Nodes::Placeholder.new(:username, @placeholders))) query.to_sql => "SELECT `users`.`id` FROM `users` WHERE `users`.`name` = ''bob''" @placeholders[:username] = "adam" query.to_sql => "SELECT `users`.`id` FROM `users` WHERE `users`.`name` = ''adam''" Make sense? Sound useful? I''m not sure that''s the most elegant API in the world (in fact I''m pretty sure it''s not), but I''m open to suggestions as to pretty ways to achieve the same thing.> >>> So... a) How can I get my bugfix merged - who should I talk to, >>> what else do you need? >>> b) What''s the best forum for discussing / getting involved in Arel >>> development. > For now, we should discuss here. I''ll open a mailing list soon, and we > can move there eventually. :-) >Okidoke :) -- 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.
Aaron, all, Did anyone have any strong feelings about the following feature - is it something that it''s going to be possible to get included (possibly in a prettied up form), or am I better forking / monkey-patching?> The idea with the placeholders is that you could have one query which > serializes differently to SQL (or through any of the visitors) > depending on the dynamic value of the placeholders. The effect I want > (and am using in my local repo) is not to have to define the values of > all the query terms at query build time: > > @placeholders = { :username => "bob" } > > query > @users.project(@users[:id]).where(@users[:name].eq(Arel::Nodes::Placeholder.new(:username, > @placeholders))) > query.to_sql => "SELECT `users`.`id` FROM `users` WHERE > `users`.`name` = ''bob''" > > @placeholders[:username] = "adam" > query.to_sql => "SELECT `users`.`id` FROM `users` WHERE `users`.`name` > = ''adam''" > > Make sense? Sound useful? I''m not sure that''s the most elegant API in > the world (in fact I''m pretty sure it''s not), but I''m open to > suggestions as to pretty ways to achieve the same thing. >The other design I considered would be: @placeholders = Arel::Placeholders.new(:username => "bob") query @users.project(@users[:id]).where(@users[:name].eq(@placeholders.for_key(:username))) query.to_sql => "SELECT `users`.`id` FROM `users` WHERE `users`.`name` = ''bob''" @placeholders.update(:username => "adam") query.to_sql => "SELECT `users`.`id` FROM `users` WHERE `users`.`name` ''adam''" which seems a little more elegant. Thanks, Arthur -- 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.
I don''t see that the use case is that compelling for the majority of Rails apps. On Tue, Apr 26, 2011 at 12:51 PM, Arthur Taylor <arthur.taylor@gmail.com>wrote:> Aaron, all, > > Did anyone have any strong feelings about the following feature - is it > something that it''s going to be possible to get included (possibly in a > prettied up form), or am I better forking / monkey-patching? > > The idea with the placeholders is that you could have one query which > > serializes differently to SQL (or through any of the visitors) > > depending on the dynamic value of the placeholders. The effect I want > > (and am using in my local repo) is not to have to define the values of > > all the query terms at query build time: > > > > @placeholders = { :username => "bob" } > > > > query > > > @users.project(@users[:id]).where(@users[:name].eq(Arel::Nodes::Placeholder.new(:username, > > @placeholders))) > > query.to_sql => "SELECT `users`.`id` FROM `users` WHERE > > `users`.`name` = ''bob''" > > > > @placeholders[:username] = "adam" > > query.to_sql => "SELECT `users`.`id` FROM `users` WHERE `users`.`name` > > = ''adam''" > > > > Make sense? Sound useful? I''m not sure that''s the most elegant API in > > the world (in fact I''m pretty sure it''s not), but I''m open to > > suggestions as to pretty ways to achieve the same thing. > > > The other design I considered would be: > > @placeholders = Arel::Placeholders.new(:username => "bob") > > query > > @users.project(@users[:id]).where(@users[:name].eq(@placeholders.for_key(:username))) > query.to_sql => "SELECT `users`.`id` FROM `users` WHERE `users`.`name` > = ''bob''" > > @placeholders.update(:username => "adam") > query.to_sql => "SELECT `users`.`id` FROM `users` WHERE `users`.`name` > ''adam''" > > which seems a little more elegant. > > Thanks, > > Arthur > > -- > 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.
Oh, there isn''t. The question is really whether the current Arel library is still useful as a standalone library (could be made useful without too much bloat) or whether Arel-standalone should be developed separately. Arthur On 26/04/11 22:05, Jason King wrote:> I don''t see that the use case is that compelling for the majority of > Rails apps . > > On Tue, Apr 26, 2011 at 12:51 PM, Arthur Taylor > <arthur.taylor@gmail.com <mailto:arthur.taylor@gmail.com>> wrote: > > Aaron, all, > > Did anyone have any strong feelings about the following feature - > is it > something that it''s going to be possible to get included (possibly > in a > prettied up form), or am I better forking / monkey-patching? > > The idea with the placeholders is that you could have one query > which > > serializes differently to SQL (or through any of the visitors) > > depending on the dynamic value of the placeholders. The effect I > want > > (and am using in my local repo) is not to have to define the > values of > > all the query terms at query build time: > > > > @placeholders = { :username => "bob" } > > > > query > > > @users.project(@users[:id]).where(@users[:name].eq(Arel::Nodes::Placeholder.new(:username, > > @placeholders))) > > query.to_sql => "SELECT `users`.`id` FROM `users` WHERE > > `users`.`name` = ''bob''" > > > > @placeholders[:username] = "adam" > > query.to_sql => "SELECT `users`.`id` FROM `users` WHERE > `users`.`name` > > = ''adam''" > > > > Make sense? Sound useful? I''m not sure that''s the most elegant > API in > > the world (in fact I''m pretty sure it''s not), but I''m open to > > suggestions as to pretty ways to achieve the same thing. > > > The other design I considered would be: > > @placeholders = Arel::Placeholders.new(:username => "bob") > > query > @users.project(@users[:id]).where(@users[:name].eq(@placeholders.for_key(:username))) > query.to_sql => "SELECT `users`.`id` FROM `users` WHERE > `users`.`name` > = ''bob''" > > @placeholders.update(:username => "adam") > query.to_sql => "SELECT `users`.`id` FROM `users` WHERE > `users`.`name` > ''adam''" > > which seems a little more elegant. > > Thanks, > > Arthur > > -- > 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 > <mailto:rubyonrails-core@googlegroups.com>. > To unsubscribe from this group, send email to > rubyonrails-core+unsubscribe@googlegroups.com > <mailto:rubyonrails-core%2Bunsubscribe@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.
Hello, *Arel *is a Relational Algebra for Ruby and if I can recall correctly at the moment it uses ActiveRecord''s connection adapters. It would be useful to make it standalone but since it''s quite dependent on Rails, any unconvincing use-cases for Rails app will never be appreciated. In that case, making it independent of Rails sounds like the first logical step. Please give your opinion. Anuj @andhapp On 26 April 2011 21:17, Arthur Taylor <arthur.taylor@gmail.com> wrote:> Oh, there isn''t. The question is really whether the current Arel library > is still useful as a standalone library (could be made useful without > too much bloat) or whether Arel-standalone should be developed separately. > > Arthur > > On 26/04/11 22:05, Jason King wrote: > > I don''t see that the use case is that compelling for the majority of > > Rails apps . > > > > On Tue, Apr 26, 2011 at 12:51 PM, Arthur Taylor > > <arthur.taylor@gmail.com <mailto:arthur.taylor@gmail.com>> wrote: > > > > Aaron, all, > > > > Did anyone have any strong feelings about the following feature - > > is it > > something that it''s going to be possible to get included (possibly > > in a > > prettied up form), or am I better forking / monkey-patching? > > > The idea with the placeholders is that you could have one query > > which > > > serializes differently to SQL (or through any of the visitors) > > > depending on the dynamic value of the placeholders. The effect I > > want > > > (and am using in my local repo) is not to have to define the > > values of > > > all the query terms at query build time: > > > > > > @placeholders = { :username => "bob" } > > > > > > query > > > > > > @users.project(@users[:id]).where(@users[:name].eq(Arel::Nodes::Placeholder.new(:username, > > > @placeholders))) > > > query.to_sql => "SELECT `users`.`id` FROM `users` WHERE > > > `users`.`name` = ''bob''" > > > > > > @placeholders[:username] = "adam" > > > query.to_sql => "SELECT `users`.`id` FROM `users` WHERE > > `users`.`name` > > > = ''adam''" > > > > > > Make sense? Sound useful? I''m not sure that''s the most elegant > > API in > > > the world (in fact I''m pretty sure it''s not), but I''m open to > > > suggestions as to pretty ways to achieve the same thing. > > > > > The other design I considered would be: > > > > @placeholders = Arel::Placeholders.new(:username => "bob") > > > > query > > > @users.project(@users[:id]).where(@users[:name].eq(@placeholders.for_key(:username))) > > query.to_sql => "SELECT `users`.`id` FROM `users` WHERE > > `users`.`name` > > = ''bob''" > > > > @placeholders.update(:username => "adam") > > query.to_sql => "SELECT `users`.`id` FROM `users` WHERE > > `users`.`name` > > ''adam''" > > > > which seems a little more elegant. > > > > Thanks, > > > > Arthur > > > > -- > > 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 > > <mailto:rubyonrails-core@googlegroups.com>. > > To unsubscribe from this group, send email to > > rubyonrails-core+unsubscribe@googlegroups.com > > <mailto:rubyonrails-core%2Bunsubscribe@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. > >-- Anuj DUTTA -- 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.
On Tue, Apr 26, 2011 at 09:51:30PM +0200, Arthur Taylor wrote:> Aaron, all, > > Did anyone have any strong feelings about the following feature - is it > something that it''s going to be possible to get included (possibly in a > prettied up form), or am I better forking / monkey-patching? > > The idea with the placeholders is that you could have one query which > > serializes differently to SQL (or through any of the visitors) > > depending on the dynamic value of the placeholders. The effect I want > > (and am using in my local repo) is not to have to define the values of > > all the query terms at query build time: > > > > @placeholders = { :username => "bob" } > > > > query > > @users.project(@users[:id]).where(@users[:name].eq(Arel::Nodes::Placeholder.new(:username, > > @placeholders))) > > query.to_sql => "SELECT `users`.`id` FROM `users` WHERE > > `users`.`name` = ''bob''" > > > > @placeholders[:username] = "adam" > > query.to_sql => "SELECT `users`.`id` FROM `users` WHERE `users`.`name` > > = ''adam''" > > > > Make sense? Sound useful? I''m not sure that''s the most elegant API in > > the world (in fact I''m pretty sure it''s not), but I''m open to > > suggestions as to pretty ways to achieve the same thing. > > > The other design I considered would be: > > @placeholders = Arel::Placeholders.new(:username => "bob") > > query > @users.project(@users[:id]).where(@users[:name].eq(@placeholders.for_key(:username))) > query.to_sql => "SELECT `users`.`id` FROM `users` WHERE `users`.`name` > = ''bob''" > > @placeholders.update(:username => "adam") > query.to_sql => "SELECT `users`.`id` FROM `users` WHERE `users`.`name` > ''adam''" > > which seems a little more elegant.No, I don''t want to include this in ARel. ARel manages an SQL AST. Since "Placeholder" isn''t part of SQL, I don''t want to support it. But that doesn''t mean you can''t subclass the visitor and add it, or monkeypatch the ToSql visitor and add support. I certainly won''t break that. -- Aaron Patterson http://tenderlovemaking.com/
On 28/04/11 00:29, Aaron Patterson wrote:> On Tue, Apr 26, 2011 at 09:51:30PM +0200, Arthur Taylor wrote: >> Aaron, all, >> >> Did anyone have any strong feelings about the following feature - is it >> something that it''s going to be possible to get included (possibly in a >> prettied up form), or am I better forking / monkey-patching? >>> The idea with the placeholders is that you could have one query which >>> serializes differently to SQL (or through any of the visitors) >>> depending on the dynamic value of the placeholders. The effect I want >>> (and am using in my local repo) is not to have to define the values of >>> all the query terms at query build time: >>> >>> @placeholders = { :username => "bob" } >>> >>> query >>> @users.project(@users[:id]).where(@users[:name].eq(Arel::Nodes::Placeholder.new(:username, >>> @placeholders))) >>> query.to_sql => "SELECT `users`.`id` FROM `users` WHERE >>> `users`.`name` = ''bob''" >>> >>> @placeholders[:username] = "adam" >>> query.to_sql => "SELECT `users`.`id` FROM `users` WHERE `users`.`name` >>> = ''adam''" >>> >>> Make sense? Sound useful? I''m not sure that''s the most elegant API in >>> the world (in fact I''m pretty sure it''s not), but I''m open to >>> suggestions as to pretty ways to achieve the same thing. >>> >> The other design I considered would be: >> >> @placeholders = Arel::Placeholders.new(:username => "bob") >> >> query >> @users.project(@users[:id]).where(@users[:name].eq(@placeholders.for_key(:username))) >> query.to_sql => "SELECT `users`.`id` FROM `users` WHERE `users`.`name` >> = ''bob''" >> >> @placeholders.update(:username => "adam") >> query.to_sql => "SELECT `users`.`id` FROM `users` WHERE `users`.`name` >> ''adam''" >> >> which seems a little more elegant. > No, I don''t want to include this in ARel. ARel manages an SQL AST. > Since "Placeholder" isn''t part of SQL, I don''t want to support it. > > But that doesn''t mean you can''t subclass the visitor and add it, or > monkeypatch the ToSql visitor and add support. I certainly won''t break > that. >Understood. Bit of a shame, but I can understand the point of keeping it pure. I''ll create a separate Gem that wraps / extends Arel and includes the additional functionality. Thanks, Arthur -- 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.
Hi again :)>>> I''ve also been playing around with support for ordering on >>> Expressions (e.g. ORDER BY COUNT(DISTINCT blah) DESC): >>> >>> https://github.com/codders/arel/commit/10a9fe64b87579592307ffbc3b18bf69c5bcf15cThis is, I''m pretty sure, allowed in the SQL-99 BNF. Would it be possible to get that merged? Thanks, Arthur -- 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.
On Thu, Apr 28, 2011 at 10:06:56AM +0200, Arthur Taylor wrote:> Hi again :) > >>>I''ve also been playing around with support for ordering on > >>>Expressions (e.g. ORDER BY COUNT(DISTINCT blah) DESC): > >>> > >>>https://github.com/codders/arel/commit/10a9fe64b87579592307ffbc3b18bf69c5bcf15c > This is, I''m pretty sure, allowed in the SQL-99 BNF. Would it be > possible to get that merged?Yup! Seems good to me. I''ll merge it. -- Aaron Patterson http://tenderlovemaking.com/
Perfect. Thanks :) On 28/04/11 19:32, Aaron Patterson wrote:> On Thu, Apr 28, 2011 at 10:06:56AM +0200, Arthur Taylor wrote: >> Hi again :) >>>>> I''ve also been playing around with support for ordering on >>>>> Expressions (e.g. ORDER BY COUNT(DISTINCT blah) DESC): >>>>> >>>>> https://github.com/codders/arel/commit/10a9fe64b87579592307ffbc3b18bf69c5bcf15c >> This is, I''m pretty sure, allowed in the SQL-99 BNF. Would it be >> possible to get that merged? > Yup! Seems good to me. I''ll merge it. >-- 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.