Sha256: c17c86a1cccab980fa58104d40bb14b8be1db231d2fc1df73c5ceba2cc14fd19
Contents?: true
Size: 909 Bytes
Versions: 1
Compression:
Stored size: 909 Bytes
Contents
# frozen_string_literal: true module TableSaw module Queries class SerialSequences QUERY = <<~SQL select pg_get_serial_sequence(kcu.table_name, kcu.column_name) as sequence, kcu.table_name as table, kcu.column_name as column from information_schema.key_column_usage as kcu inner join information_schema.table_constraints as tc on tc.constraint_name = kcu.constraint_name where tc.constraint_type = 'PRIMARY KEY' and pg_get_serial_sequence(kcu.table_name, kcu.column_name) is not null SQL SerialSequence = Struct.new(:name, :table, :column) 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 end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
table_saw-3.2.0 | lib/table_saw/queries/serial_sequences.rb |