Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fix for incompatibility between Sequel and Arel in Rails 3.2.8. #135

Closed
wants to merge 2 commits into from

4 participants

@fimmtiu

Fixes the issue introduced by commit rails/rails@a1c05dd and discussed in issue rails/arel#133.

It's not the ideal solution, but it's only three lines and seems to do the trick.

(And yes, there are apps that use both Sequel and ActiveRecord.)

@ernie
Collaborator

I'm -1 on this. I offered that solution as something that Sequel could patch in via a compatibility fix, but otherwise, this discussion (and any fix) should remain on AR, where the node gets created, not ARel, IMHO.

@tenderlove
Owner
@sheerun

I guess this should be closed

@ernie ernie closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 15 additions and 0 deletions.
  1. +4 −0 lib/arel/visitors/to_sql.rb
  2. +11 −0 test/visitors/test_to_sql.rb
View
4 lib/arel/visitors/to_sql.rb
@@ -474,6 +474,10 @@ def visit_Arel_Nodes_InfixOperation o
alias :visit_Arel_Nodes_Multiplication :visit_Arel_Nodes_InfixOperation
alias :visit_Arel_Nodes_Division :visit_Arel_Nodes_InfixOperation
+ def visit_Sequel_SQL_AliasedExpression o
+ "#{o.expression} AS #{o.aliaz}"
+ end
+
def visit_Array o
o.map { |x| visit x }.join(', ')
end
View
11 test/visitors/test_to_sql.rb
@@ -344,6 +344,17 @@ def quote value, column = nil
end
end
end
+
+ begin
+ require 'sequel'
+ it "should visit_Sequel_SQL_AliasedExpression if Sequel is present" do
+ [:to_sym, :to_s].each do |fn|
+ sql = @visitor.accept Sequel::SQL::AliasedExpression.new(*%w(foo bar).map(&fn))
+ sql.must_be_like "foo AS bar"
+ end
+ end
+ rescue LoadError
+ end
end
end
end
Something went wrong with that request. Please try again.