未验证 提交 8c3bf602 编写于 作者: R Ryuta Kamizono 提交者: GitHub

Merge pull request #33004 from nlpgo/master

Fix: Arel Postgresql visitor generates invalid SQL for GROUPING SETS.
......@@ -5,7 +5,7 @@ module Visitors
class PostgreSQL < Arel::Visitors::ToSql
CUBE = "CUBE"
ROLLUP = "ROLLUP"
GROUPING_SET = "GROUPING SET"
GROUPING_SETS = "GROUPING SETS"
LATERAL = "LATERAL"
private
......@@ -67,7 +67,7 @@ def visit_Arel_Nodes_RollUp(o, collector)
end
def visit_Arel_Nodes_GroupingSet(o, collector)
collector << GROUPING_SET
collector << GROUPING_SETS
grouping_array_or_grouping_element o, collector
end
......
......@@ -229,7 +229,7 @@ def compile(node)
it "should know how to visit with array arguments" do
node = Arel::Nodes::GroupingSet.new([@table[:name], @table[:bool]])
compile(node).must_be_like %{
GROUPING SET( "users"."name", "users"."bool" )
GROUPING SETS( "users"."name", "users"."bool" )
}
end
......@@ -237,7 +237,7 @@ def compile(node)
group = Arel::Nodes::GroupingElement.new([@table[:name], @table[:bool]])
node = Arel::Nodes::GroupingSet.new(group)
compile(node).must_be_like %{
GROUPING SET( "users"."name", "users"."bool" )
GROUPING SETS( "users"."name", "users"."bool" )
}
end
......@@ -246,7 +246,7 @@ def compile(node)
group2 = Arel::Nodes::GroupingElement.new([@table[:bool], @table[:created_at]])
node = Arel::Nodes::GroupingSet.new([group1, group2])
compile(node).must_be_like %{
GROUPING SET( ( "users"."name" ), ( "users"."bool", "users"."created_at" ) )
GROUPING SETS( ( "users"."name" ), ( "users"."bool", "users"."created_at" ) )
}
end
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册