Commit 1319a9ed authored by Yorick Peterse's avatar Yorick Peterse

Merge branch '8798-geo-implement-selective-sync-support-for-the-various-fdw-queries' into 'master'

Replace dots with an underscore when creating an alias for the recursive CTE

See merge request gitlab-org/gitlab-ce!25112
parents 93725519 9100ca18
......@@ -48,7 +48,7 @@ module Gitlab
#
# alias_table - The Arel table to use as the alias.
def alias_to(alias_table)
Arel::Nodes::As.new(table, alias_table)
Arel::Nodes::As.new(table, Arel::Table.new(alias_table.name.tr('.', '_')))
end
# Applies the CTE to the given relation, returning a new one that will
......
......@@ -31,6 +31,15 @@ describe Gitlab::SQL::RecursiveCTE, :postgresql do
expect(cte.alias_to(table).to_sql).to eq("#{source_name} AS #{alias_name}")
end
it 'replaces dots with an underscore' do
table = Arel::Table.new('gitlab.kittens')
source_name = ActiveRecord::Base.connection.quote_table_name(:cte_name)
alias_name = ActiveRecord::Base.connection.quote_table_name(:gitlab_kittens)
expect(cte.alias_to(table).to_sql).to eq("#{source_name} AS #{alias_name}")
end
end
describe '#apply_to' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment