Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Barbosa Alexandre <dbalexandre@gmail.com>2019-02-11 22:36:57 +0300
committerDouglas Barbosa Alexandre <dbalexandre@gmail.com>2019-02-11 23:06:54 +0300
commit9100ca188c45f2129d5e891534ed38718ef67e46 (patch)
tree69d9c170947fc4c2e3f1009386ec1762a5024509 /spec/lib/gitlab/sql
parenta1215556ec6c5ab84862519b82cee99645dad357 (diff)
Replace dots with an underscore when creating an alias for the CTE
When the Arel table to use as the alias contains a schema in your name, e.g., "gitlab_secondary"."namespaces" it produces an invalid query.
Diffstat (limited to 'spec/lib/gitlab/sql')
-rw-r--r--spec/lib/gitlab/sql/recursive_cte_spec.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/spec/lib/gitlab/sql/recursive_cte_spec.rb b/spec/lib/gitlab/sql/recursive_cte_spec.rb
index 25146860615..7fe39dd5a96 100644
--- a/spec/lib/gitlab/sql/recursive_cte_spec.rb
+++ b/spec/lib/gitlab/sql/recursive_cte_spec.rb
@@ -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