Permalink
Browse files

fixing my bad merge. doh!

  • Loading branch information...
1 parent 8fedb5f commit 9848b47281ccd519bdbb6f1c80802bffbb11a730 @tenderlove tenderlove committed Nov 18, 2011
@@ -572,10 +572,12 @@ def show_variable(name)
# Returns a table's primary key and belonging sequence.
def pk_and_sequence_for(table)
- execute_and_free("DESCRIBE #{quote_table_name(table)}", 'SCHEMA') do |result|
- keys = each_hash(result).select { |row| row[:Key] == 'PRI' }.map { |row| row[:Field] }
- keys.length == 1 ? [keys.first, nil] : nil
+ keys = []
+ result = execute("DESCRIBE #{quote_table_name(table)}", 'SCHEMA')
+ result.each(:symbolize_keys => true, :as => :hash) do |row|
+ keys << row[:Field] if row[:Key] == 'PRI'
end
+ keys.length == 1 ? [keys.first, nil] : nil
end
def detailed_pk_and_sequence_for(table) #:nodoc:
@@ -755,10 +755,13 @@ def show_variable(name)
# Returns a table's primary key and belonging sequence.
def pk_and_sequence_for(table) #:nodoc:
- execute_and_free("DESCRIBE #{quote_table_name(table)}", 'SCHEMA') do |result|
- keys = each_hash(result).select { |row| row[:Key] == 'PRI' }.map { |row| row[:Field] }
- keys.length == 1 ? [keys.first, nil] : nil
+ keys = []
+ result = execute("DESCRIBE #{quote_table_name(table)}", 'SCHEMA')
+ result.each_hash do |row|
+ keys << row['Field'] if row['Key'] == 'PRI'
end
+ result.free
+ keys.length == 1 ? [keys.first, nil] : nil
end
def detailed_pk_and_sequence_for(table) #:nodoc:

0 comments on commit 9848b47

Please sign in to comment.