Created
October 28, 2021 20:01
-
-
Save DNA/b953f7b4619d9f38577cf22049629a29 to your computer and use it in GitHub Desktop.
Fix Rails SQL Server Adapter when using Arel::Nodes::TableAlias
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
module Arel | |
module Visitors | |
class SQLServer < Arel::Visitors::ToSql | |
def table_From_Statement o | |
core = o.cores.first | |
table_From_Node(core.from) || table_From_Node(core.source) | |
end | |
def table_From_Node n | |
case n | |
when Arel::Table then n | |
when Arel::Nodes::TableAlias then n | |
when Arel::Nodes::SqlLiteral then Arel::Table.new(n) | |
when Arel::Nodes::JoinSource then table_From_Node(n.left) || table_From_Node(n.right) | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment