Commit 5b52f8c6 authored by Nick Thomas's avatar Nick Thomas

Merge branch 'sh-improve-fdw-comparison' into 'master'

Geo: Fix FDW schema check when tables and columns are not in the same order

See merge request gitlab-org/gitlab-ee!5841
parents 8069cb32 a4b5836b
---
title: 'Geo: Fix FDW schema check when tables and columns are not in the same order'
merge_request:
author:
type: fixed
...@@ -75,7 +75,7 @@ module Gitlab ...@@ -75,7 +75,7 @@ module Gitlab
Gitlab::Geo.cache_value(:geo_fdw_schema_tables_match) do Gitlab::Geo.cache_value(:geo_fdw_schema_tables_match) do
schema = gitlab_schema schema = gitlab_schema
schema.present? && schema == fdw_schema schema.present? && (schema.to_set == fdw_schema.to_set)
end end
end end
......
...@@ -172,6 +172,19 @@ describe Gitlab::Geo::Fdw, :geo do ...@@ -172,6 +172,19 @@ describe Gitlab::Geo::Fdw, :geo do
# rake geo:db:test:refresh_foreign_tables # rake geo:db:test:refresh_foreign_tables
expect(described_class.foreign_schema_tables_match?).to be_truthy expect(described_class.foreign_schema_tables_match?).to be_truthy
end end
it 'returns true if order is different' do
one_schema = [
{ "table_name" => "events", "column_name" => "target_type", "data_type" => "character varying" },
{ "table_name" => "ci_job_artifacts", "column_name" => "id", "data_type" => "integer" }
]
second_schema = one_schema.reverse
allow(described_class).to receive(:gitlab_schema).and_return(one_schema)
allow(described_class).to receive(:fdw_schema).and_return(second_schema)
expect(described_class.foreign_schema_tables_match?).to be_truthy
end
end end
end end
end end
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