Module: Sequel::PGTools
- Defined in:
- lib/sequel/extensions/pg_tools.rb
Overview
Extension with some tools that use pg internal tables and views
Instance Method Summary collapse
-
#inherited_tables_for(table_name, schema: :public) ⇒ Array<Symbol>
List inherited tables for specific parent table.
Instance Method Details
#inherited_tables_for(table_name, schema: :public) ⇒ Array<Symbol>
List inherited tables for specific parent table
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/sequel/extensions/pg_tools.rb', line 18 def inherited_tables_for(table_name, schema: :public) self[:pg_inherits] .select(Sequel[:cn][:nspname].as(:schema), Sequel[:c][:relname].as(:child)) .left_join(Sequel[:pg_class].as(:c), Sequel[:inhrelid] => Sequel[:c][:oid]) .left_join(Sequel[:pg_class].as(:p), Sequel[:inhparent] => Sequel[:p][:oid]) .left_join(Sequel[:pg_namespace].as(:pn), Sequel[:pn][:oid] => Sequel[:p][:relnamespace]) .left_join(Sequel[:pg_namespace].as(:cn), Sequel[:cn][:oid] => Sequel[:c][:relnamespace]) .where(Sequel[:p][:relname] => table_name.to_s, Sequel[:pn][:nspname] => schema.to_s) .to_a .map { |x| x[:child].to_sym } end |