lib/sequel/adapters/shared/mysql.rb in sequel-4.38.0 vs lib/sequel/adapters/shared/mysql.rb in sequel-4.39.0

- old
+ new

@@ -7,10 +7,18 @@ Dataset::NON_SQL_OPTIONS << :insert_ignore Dataset::NON_SQL_OPTIONS << :update_ignore Dataset::NON_SQL_OPTIONS << :on_duplicate_key_update module MySQL + Sequel::Database.set_shared_adapter_scheme(:mysql, self) + + def self.mock_adapter_setup(db) + db.instance_eval do + @server_version = 50617 + end + end + @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 @@ -186,20 +194,25 @@ end private def alter_table_add_column_sql(table, op) - if related = op.delete(:table) - sql = super.dup + pos = if after_col = op[:after] + " AFTER #{quote_identifier(after_col)}" + elsif op[:first] + " FIRST" + end + + sql = if related = op.delete(:table) + sql = super + "#{pos}, ADD " op[:table] = related op[:key] ||= primary_key_from_schema(related) - sql << ", ADD " if constraint_name = op.delete(:foreign_key_constraint_name) sql << "CONSTRAINT #{quote_identifier(constraint_name)} " end sql << "FOREIGN KEY (#{quote_identifier(op[:name])})#{column_references_sql(op)}" else - super + "#{super}#{pos}" end end def alter_table_change_column_sql(table, op) o = op[:op]