class PgDice::PartitionLister
PartitionLister
is used to list partitions
Attributes
query_executor[R]
Public Class Methods
new(query_executor:)
click to toggle source
# File lib/pgdice/partition_lister.rb, line 9 def initialize(query_executor:) @query_executor = query_executor end
Public Instance Methods
call(all_params)
click to toggle source
# File lib/pgdice/partition_lister.rb, line 13 def call(all_params) sql = build_partition_table_fetch_sql(all_params) query_executor.call(sql) end
Private Instance Methods
build_partition_table_fetch_sql(params = {})
click to toggle source
# File lib/pgdice/partition_lister.rb, line 20 def build_partition_table_fetch_sql(params = {}) schema = params.fetch(:schema, 'public') base_table_name = params.fetch(:table_name) <<~SQL SELECT tablename FROM pg_tables WHERE schemaname = '#{schema}' AND tablename ~ '^#{base_table_name}_\\d+$' ORDER BY tablename; SQL end