Class: ActiveRecord::ConnectionAdapters::MysqlAdapter
- Inherits:
-
AbstractAdapter
- Object
- AbstractAdapter
- ActiveRecord::ConnectionAdapters::MysqlAdapter
- Defined in:
- lib/taps/adapter_hacks/mysql_invalid_primary_key.rb
Instance Method Summary collapse
- #orig_pk_and_sequence_for ⇒ Object
-
#pk_and_sequence_for(table) ⇒ Object
mysql accepts varchar as a primary key but most others do not.
Instance Method Details
#orig_pk_and_sequence_for ⇒ Object
4 |
# File 'lib/taps/adapter_hacks/mysql_invalid_primary_key.rb', line 4 alias_method :orig_pk_and_sequence_for, :pk_and_sequence_for |
#pk_and_sequence_for(table) ⇒ Object
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
8 9 10 11 12 13 14 |
# File 'lib/taps/adapter_hacks/mysql_invalid_primary_key.rb', line 8 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 |