Class: RDBr::Catalog::Postgresql
- Defined in:
- lib/rdbr/catalog/postgresql.rb
Constant Summary collapse
- RELATION_KINDS =
{ 'r' => :table, 'p' => :partitioned_table, 'v' => :view, 'm' => :materialized_view, 'f' => :foreign_table }.freeze
- FOREIGN_KEY_ACTIONS =
{ 'a' => :no_action, 'r' => :restrict, 'c' => :cascade, 'n' => :set_null, 'd' => :set_default }.freeze
- IDENTITY_KINDS =
{ 'a' => :always, 'd' => :by_default }.freeze
Instance Method Summary collapse
-
#initialize(connection, include_system: false) ⇒ Postgresql
constructor
A new instance of Postgresql.
- #read ⇒ Object
Methods inherited from Reader
Constructor Details
#initialize(connection, include_system: false) ⇒ Postgresql
Returns a new instance of Postgresql.
22 23 24 25 26 27 28 29 |
# File 'lib/rdbr/catalog/postgresql.rb', line 22 def initialize(connection, include_system: false) super @queries = PostgresqlQueries.new( connection, include_system: include_system, generated_columns: generated_columns_supported?(connection.database_version) ) end |
Instance Method Details
#read ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/rdbr/catalog/postgresql.rb', line 31 def read relations_by_namespace = queries.relations.group_by{|row| row.fetch('namespace_name') } namespaces = queries.namespaces.map do |namespace| rows = relations_by_namespace.fetch(namespace.fetch('name'), []) Metadata::Namespace.new(name: namespace.fetch('name'), relations: rows.map{|row| build_relation(row) }) end Metadata::Database.new(name: database_name, adapter: :postgresql, namespaces: namespaces) end |