the array of colmuns that make up the primary key of the table since a primary key has an index, we loop over all the indexes for the table and pick the first one that is unique, and all the columns in the index have primary_key? as true.
we do this instead of just looking for the columns where primary key is true because we want the columns in primary key order
# File lib/amalgalite/table.rb, line 63 def primary_key unless @primary_key pk_column_names = Set.new( primary_key_columns.collect { |c| c.name } ) unique_indexes = indexes.values.find_all { |i| i.unique? } pk_result = [] unique_indexes.each do |idx| idx_column_names = Set.new( idx.columns.collect { |c| c.name } ) r = idx_column_names ^ pk_column_names if r.size == 0 then pk_result = idx.columns break end end # no joy, see about just using all the columns that say the are primary # keys if pk_result.empty? then pk_result = self.primary_key_columns end @primary_key = pk_result end return @primary_key end