Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

use a recursive lambda for finding a table object from a select state…

…ment.
  • Loading branch information...
commit 8fc0587ff375abbe30e589e70cde4d7859fced6e 1 parent 894a3fc
@metaskills metaskills authored
Showing with 6 additions and 9 deletions.
  1. +6 −9 lib/arel/visitors/sqlserver.rb
View
15 lib/arel/visitors/sqlserver.rb
@@ -203,20 +203,17 @@ def table_from_select_statement(o)
# elsif Arel::Nodes::JoinSource === core.source
# Arel::Nodes::SqlLiteral === core.source.left ? Arel::Table.new(core.source.left, @engine) : core.source.left
# end
- if Arel::Table === core.froms
- core.froms
- elsif Arel::Nodes::SqlLiteral === core.froms
- Arel::Table.new(core.froms, @engine)
- elsif Arel::Nodes::Join === core.froms
- case x = core.froms.left
+ table_finder = lambda { |x|
+ case x
when Arel::Table
x
when Arel::Nodes::SqlLiteral
Arel::Table.new(x, @engine)
- when Arel::Nodes::OuterJoin
- x.left
+ when Arel::Nodes::Join
+ table_finder.call(x.left)
end
- end
+ }
+ table_finder.call(core.froms)
end
def single_distinct_select_statement?(o)
Please sign in to comment.
Something went wrong with that request. Please try again.