Class: TableSaw::Queries::SerialSequences

Inherits:
Object
  • Object
show all
Defined in:
lib/table_saw/queries/serial_sequences.rb

Defined Under Namespace

Classes: SerialSequence

Constant Summary collapse

QUERY =
"select\n  pg_get_serial_sequence(kcu.table_name, kcu.column_name) as sequence,\n  kcu.table_name as table,\n  kcu.column_name as column\nfrom information_schema.key_column_usage as kcu\n         inner join information_schema.table_constraints as tc\n                    on tc.constraint_name = kcu.constraint_name\nwhere tc.constraint_type = 'PRIMARY KEY'\n  and pg_get_serial_sequence(kcu.table_name, kcu.column_name) is not null\n"

Instance Method Summary collapse

Instance Method Details

#callObject



20
21
22
23
24
# File 'lib/table_saw/queries/serial_sequences.rb', line 20

def call
  TableSaw.connection.exec_query(QUERY).each_with_object({}) do |row, memo|
    memo[row['table']] = SerialSequence.new(row['sequence'], row['table'], row['column'])
  end
end