lib/sequel/adapters/shared/mysql.rb in sequel-3.14.0 vs lib/sequel/adapters/shared/mysql.rb in sequel-3.15.0

- old
+ new

@@ -1,11 +1,19 @@ module Sequel Dataset::NON_SQL_OPTIONS << :insert_ignore Dataset::NON_SQL_OPTIONS << :on_duplicate_key_update module MySQL + @convert_tinyint_to_bool = true + class << self + # Sequel converts the column type tinyint(1) to a boolean by default when + # using the native MySQL or Mysql2 adapter. You can turn off the conversion by setting + # this to false. This setting is ignored when connecting to MySQL via the do or jdbc + # adapters, both of which automatically do the conversion. + attr_accessor :convert_tinyint_to_bool + # Set the default charset used for CREATE TABLE. You can pass the # :charset option to create_table to override this setting. attr_accessor :default_charset # Set the default collation used for CREATE TABLE. You can pass the @@ -231,10 +239,10 @@ # Use the MySQL specific DESCRIBE syntax to get a table description. def schema_parse_table(table_name, opts) m = output_identifier_meth im = input_identifier_meth metadata_dataset.with_sql("DESCRIBE ?", SQL::Identifier.new(im.call(table_name))).map do |row| - row.delete(:Extra) + row[:auto_increment] = true if row.delete(:Extra).to_s =~ /auto_increment/io row[:allow_null] = row.delete(:Null) == 'YES' row[:default] = row.delete(:Default) row[:primary_key] = row.delete(:Key) == 'PRI' row[:default] = nil if blank_object?(row[:default]) row[:db_type] = row.delete(:Type)