Skip to content

Commit

Permalink
Merge pull request #29519 from Edouard-chin/ec-structure-flags-order
Browse files Browse the repository at this point in the history
Pass `structure_dump_flags` / `structure_load_flags` options before any other:
  • Loading branch information
rafaelfranca committed Jun 26, 2017
2 parents 9105a8e + 8f1486f commit 229d8b2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions activerecord/lib/active_record/tasks/mysql_database_tasks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ def structure_dump(filename, extra_flags)
args.concat(["--no-data"])
args.concat(["--routines"])
args.concat(["--skip-comments"])
args.concat(Array(extra_flags)) if extra_flags

ignore_tables = ActiveRecord::SchemaDumper.ignore_tables
if ignore_tables.any?
args += ignore_tables.map { |table| "--ignore-table=#{configuration['database']}.#{table}" }
end

args.concat(["#{configuration['database']}"])
args.unshift(*extra_flags) if extra_flags

run_cmd("mysqldump", args, "dumping")
end
Expand All @@ -75,7 +75,7 @@ def structure_load(filename, extra_flags)
args = prepare_command_options
args.concat(["--execute", %{SET FOREIGN_KEY_CHECKS = 0; SOURCE #{filename}; SET FOREIGN_KEY_CHECKS = 1}])
args.concat(["--database", "#{configuration['database']}"])
args.concat(Array(extra_flags)) if extra_flags
args.unshift(*extra_flags) if extra_flags

run_cmd("mysql", args, "loading")
end
Expand Down
4 changes: 2 additions & 2 deletions activerecord/test/cases/tasks/mysql_rake_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ def test_structure_dump

def test_structure_dump_with_extra_flags
filename = "awesome-file.sql"
expected_command = ["mysqldump", "--result-file", filename, "--no-data", "--routines", "--skip-comments", "--noop", "test-db"]
expected_command = ["mysqldump", "--noop", "--result-file", filename, "--no-data", "--routines", "--skip-comments", "test-db"]

assert_called_with(Kernel, :system, expected_command, returns: true) do
with_structure_dump_flags(["--noop"]) do
Expand Down Expand Up @@ -364,7 +364,7 @@ def setup

def test_structure_load
filename = "awesome-file.sql"
expected_command = ["mysql", "--execute", %{SET FOREIGN_KEY_CHECKS = 0; SOURCE #{filename}; SET FOREIGN_KEY_CHECKS = 1}, "--database", "test-db", "--noop"]
expected_command = ["mysql", "--noop", "--execute", %{SET FOREIGN_KEY_CHECKS = 0; SOURCE #{filename}; SET FOREIGN_KEY_CHECKS = 1}, "--database", "test-db"]

assert_called_with(Kernel, :system, expected_command, returns: true) do
with_structure_load_flags(["--noop"]) do
Expand Down

0 comments on commit 229d8b2

Please sign in to comment.