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:
Diffstat (limited to 'gems/gitlab-schema-validation/lib/gitlab/schema/validation/sources/connection_adapters/pg_adapter.rb')
-rw-r--r--gems/gitlab-schema-validation/lib/gitlab/schema/validation/sources/connection_adapters/pg_adapter.rb30
1 files changed, 30 insertions, 0 deletions
diff --git a/gems/gitlab-schema-validation/lib/gitlab/schema/validation/sources/connection_adapters/pg_adapter.rb b/gems/gitlab-schema-validation/lib/gitlab/schema/validation/sources/connection_adapters/pg_adapter.rb
new file mode 100644
index 00000000000..4dcaf15be71
--- /dev/null
+++ b/gems/gitlab-schema-validation/lib/gitlab/schema/validation/sources/connection_adapters/pg_adapter.rb
@@ -0,0 +1,30 @@
+# frozen_string_literal: true
+
+module Gitlab
+ module Schema
+ module Validation
+ module Sources
+ module ConnectionAdapters
+ class PgAdapter < Base
+ def initialize(connection)
+ @connection = connection
+ @connection.type_map_for_results = PG::BasicTypeMapForResults.new(connection)
+ end
+
+ def current_schema
+ connection.exec('SELECT current_schema').first['current_schema']
+ end
+
+ def exec_query(sql, schemas)
+ connection.exec(sql, schemas)
+ end
+
+ def select_rows(sql, schemas)
+ exec_query(sql, schemas).values
+ end
+ end
+ end
+ end
+ end
+ end
+end