Sha256: a584d1e59573930d2d9e7dd575fae0c606d0ca4b30db86b98ca3b4d5eb84adbb
Contents?: true
Size: 904 Bytes
Versions: 22
Compression:
Stored size: 904 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).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
22 entries across 22 versions & 1 rubygems