The visitor for And/Or nodes is overridden in to_sql:
https://github.com/Faveod/arel-extensions/blob/master/lib/arel_extensions/visitors/to_sql.rb#L561-L579
However, this causes broken sql when adding a condition to an On node:
Arel::Nodes::On.new(Post.arel_table[:user_id].eq(User.arel_table[:id])).to_sql
=> "ON `posts`.`user_id` = `users`.`id`"
Arel::Nodes::On.new(Post.arel_table[:user_id].eq(User.arel_table[:id]))
.and(Post.arel_table[:type].eq('foo')).to_sql
=> "(ON `posts`.`user_id` = `users`.`id`) AND (`posts`.`type` = 'foo')"
As you can see, the entire original ON got parenthesized, which leads to a SQL syntax error.
I'm using Rails 6.1.4.1.
The visitor for And/Or nodes is overridden in to_sql:
https://github.com/Faveod/arel-extensions/blob/master/lib/arel_extensions/visitors/to_sql.rb#L561-L579
However, this causes broken sql when adding a condition to an On node:
As you can see, the entire original
ONgot parenthesized, which leads to a SQL syntax error.I'm using Rails 6.1.4.1.