Sha256: ee9fb41933459e6439646f57bcb664e47594d8b82760e67cfb6668b851b4ccfb

Contents?: true

Size: 588 Bytes

Versions: 19

Compression:

Stored size: 588 Bytes

Contents

module ActiveRecord
	module ConnectionAdapters
		class MysqlAdapter < AbstractAdapter
			alias_method :orig_pk_and_sequence_for, :pk_and_sequence_for
			# mysql accepts varchar as a primary key but most others do not.
			# only say that a field is a primary key if mysql says so
			# and the field is a kind of integer
			def pk_and_sequence_for(table)
				keys = []
				execute("describe #{quote_table_name(table)}").each_hash do |h|
					keys << h["Field"] if h["Key"] == "PRI" and !(h["Type"] =~ /int/).nil?
				end
				keys.length == 1 ? [keys.first, nil] : nil
			end
		end
	end
end

Version data entries

19 entries across 19 versions & 3 rubygems

Version Path
ricardochimal-taps-0.2.14 lib/taps/adapter_hacks/mysql_invalid_primary_key.rb
ricardochimal-taps-0.2.15 lib/taps/adapter_hacks/mysql_invalid_primary_key.rb
ricardochimal-taps-0.2.16 lib/taps/adapter_hacks/mysql_invalid_primary_key.rb
ricardochimal-taps-0.2.18 lib/taps/adapter_hacks/mysql_invalid_primary_key.rb
ricardochimal-taps-0.2.19 lib/taps/adapter_hacks/mysql_invalid_primary_key.rb
taps-0.2.26 lib/taps/adapter_hacks/mysql_invalid_primary_key.rb
taps-0.2.25 lib/taps/adapter_hacks/mysql_invalid_primary_key.rb
taps-0.2.24 lib/taps/adapter_hacks/mysql_invalid_primary_key.rb
taps-0.2.23 lib/taps/adapter_hacks/mysql_invalid_primary_key.rb
taps-0.2.22 lib/taps/adapter_hacks/mysql_invalid_primary_key.rb
taps-0.2.21 lib/taps/adapter_hacks/mysql_invalid_primary_key.rb
taps-0.2.20 lib/taps/adapter_hacks/mysql_invalid_primary_key.rb
matthewtodd-taps-0.2.19 lib/taps/adapter_hacks/mysql_invalid_primary_key.rb
taps-0.2.19 lib/taps/adapter_hacks/mysql_invalid_primary_key.rb
taps-0.2.15 lib/taps/adapter_hacks/mysql_invalid_primary_key.rb
taps-0.2.14 lib/taps/adapter_hacks/mysql_invalid_primary_key.rb
taps-0.2.16 lib/taps/adapter_hacks/mysql_invalid_primary_key.rb
taps-0.2.18 lib/taps/adapter_hacks/mysql_invalid_primary_key.rb
taps-0.2.17 lib/taps/adapter_hacks/mysql_invalid_primary_key.rb