From 71068365d0cd3e77de30b4d8d2a53d65f215c035 Mon Sep 17 00:00:00 2001 From: Alex Dent Date: Thu, 30 Dec 2021 16:52:54 +1300 Subject: [PATCH] Updating the --no-comment argument to the correct --no-comments argument --- activerecord/CHANGELOG.md | 6 +++++ .../tasks/postgresql_database_tasks.rb | 2 +- .../test/cases/tasks/postgresql_rake_test.rb | 22 +++++++++---------- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md index 1fff96ae30..a05d551051 100644 --- a/activerecord/CHANGELOG.md +++ b/activerecord/CHANGELOG.md @@ -1,3 +1,9 @@ +* Fix incorrect argument in PostgreSQL structure dump tasks. + + Updating the `--no-comment` argument added in Rails 7 to the correct `--no-comments` argument. + + *Alex Dent* + * Fix migration compatibility to create SQLite references/belongs_to column as integer when migration version is 6.0. Reference/belongs_to in migrations with version 6.0 were creating columns as diff --git a/activerecord/lib/active_record/tasks/postgresql_database_tasks.rb b/activerecord/lib/active_record/tasks/postgresql_database_tasks.rb index 3913ef938f..fb74184c29 100644 --- a/activerecord/lib/active_record/tasks/postgresql_database_tasks.rb +++ b/activerecord/lib/active_record/tasks/postgresql_database_tasks.rb @@ -58,7 +58,7 @@ module ActiveRecord end args = ["--schema-only", "--no-privileges", "--no-owner"] - args << "--no-comment" if connection.database_version >= 110_000 + args << "--no-comments" if connection.database_version >= 110_000 args.concat(["--file", filename]) args.concat(Array(extra_flags)) if extra_flags diff --git a/activerecord/test/cases/tasks/postgresql_rake_test.rb b/activerecord/test/cases/tasks/postgresql_rake_test.rb index 62c99099e3..9be417db2b 100644 --- a/activerecord/test/cases/tasks/postgresql_rake_test.rb +++ b/activerecord/test/cases/tasks/postgresql_rake_test.rb @@ -355,7 +355,7 @@ if current_adapter?(:PostgreSQLAdapter) assert_called_with( Kernel, :system, - [{}, "pg_dump", "--schema-only", "--no-privileges", "--no-owner", "--no-comment", "--file", @filename, "my-app-db"], + [{}, "pg_dump", "--schema-only", "--no-privileges", "--no-owner", "--no-comments", "--file", @filename, "my-app-db"], returns: true ) do ActiveRecord::Tasks::DatabaseTasks.structure_dump(@configuration, @filename) @@ -373,7 +373,7 @@ if current_adapter?(:PostgreSQLAdapter) def test_structure_dump_with_env expected_env = { "PGHOST" => "my.server.tld", "PGPORT" => "2345", "PGUSER" => "jane", "PGPASSWORD" => "s3cr3t" } - expected_command = [expected_env, "pg_dump", "--schema-only", "--no-privileges", "--no-owner", "--no-comment", "--file", @filename, "my-app-db"] + expected_command = [expected_env, "pg_dump", "--schema-only", "--no-privileges", "--no-owner", "--no-comments", "--file", @filename, "my-app-db"] assert_called_with(Kernel, :system, expected_command, returns: true) do ActiveRecord::Tasks::DatabaseTasks.structure_dump( @@ -385,7 +385,7 @@ if current_adapter?(:PostgreSQLAdapter) def test_structure_dump_with_ssl_env expected_env = { "PGSSLMODE" => "verify-full", "PGSSLCERT" => "client.crt", "PGSSLKEY" => "client.key", "PGSSLROOTCERT" => "root.crt" } - expected_command = [expected_env, "pg_dump", "--schema-only", "--no-privileges", "--no-owner", "--no-comment", "--file", @filename, "my-app-db"] + expected_command = [expected_env, "pg_dump", "--schema-only", "--no-privileges", "--no-owner", "--no-comments", "--file", @filename, "my-app-db"] assert_called_with(Kernel, :system, expected_command, returns: true) do ActiveRecord::Tasks::DatabaseTasks.structure_dump( @@ -396,7 +396,7 @@ if current_adapter?(:PostgreSQLAdapter) end def test_structure_dump_with_extra_flags - expected_command = [{}, "pg_dump", "--schema-only", "--no-privileges", "--no-owner", "--no-comment", "--file", @filename, "--noop", "my-app-db"] + expected_command = [{}, "pg_dump", "--schema-only", "--no-privileges", "--no-owner", "--no-comments", "--file", @filename, "--noop", "my-app-db"] assert_called_with(Kernel, :system, expected_command, returns: true) do with_structure_dump_flags(["--noop"]) do @@ -406,7 +406,7 @@ if current_adapter?(:PostgreSQLAdapter) end def test_structure_dump_with_hash_extra_flags_for_a_different_driver - expected_command = [{}, "pg_dump", "--schema-only", "--no-privileges", "--no-owner", "--no-comment", "--file", @filename, "my-app-db"] + expected_command = [{}, "pg_dump", "--schema-only", "--no-privileges", "--no-owner", "--no-comments", "--file", @filename, "my-app-db"] assert_called_with(Kernel, :system, expected_command, returns: true) do with_structure_dump_flags({ mysql2: ["--noop"] }) do @@ -416,7 +416,7 @@ if current_adapter?(:PostgreSQLAdapter) end def test_structure_dump_with_hash_extra_flags_for_the_correct_driver - expected_command = [{}, "pg_dump", "--schema-only", "--no-privileges", "--no-owner", "--no-comment", "--file", @filename, "--noop", "my-app-db"] + expected_command = [{}, "pg_dump", "--schema-only", "--no-privileges", "--no-owner", "--no-comments", "--file", @filename, "--noop", "my-app-db"] assert_called_with(Kernel, :system, expected_command, returns: true) do with_structure_dump_flags({ postgresql: ["--noop"] }) do @@ -434,7 +434,7 @@ if current_adapter?(:PostgreSQLAdapter) assert_called_with( Kernel, :system, - [{}, "pg_dump", "--schema-only", "--no-privileges", "--no-owner", "--no-comment", "--file", @filename, "-T", "foo", "-T", "bar", "my-app-db"], + [{}, "pg_dump", "--schema-only", "--no-privileges", "--no-owner", "--no-comments", "--file", @filename, "-T", "foo", "-T", "bar", "my-app-db"], returns: true ) do ActiveRecord::Tasks::DatabaseTasks.structure_dump(@configuration, @filename) @@ -448,7 +448,7 @@ if current_adapter?(:PostgreSQLAdapter) assert_called_with( Kernel, :system, - [{}, "pg_dump", "--schema-only", "--no-privileges", "--no-owner", "--no-comment", "--file", @filename, "--schema=foo", "--schema=bar", "my-app-db"], + [{}, "pg_dump", "--schema-only", "--no-privileges", "--no-owner", "--no-comments", "--file", @filename, "--schema=foo", "--schema=bar", "my-app-db"], returns: true ) do ActiveRecord::Tasks::DatabaseTasks.structure_dump(@configuration, @filename) @@ -461,7 +461,7 @@ if current_adapter?(:PostgreSQLAdapter) assert_called_with( Kernel, :system, - [{}, "pg_dump", "--schema-only", "--no-privileges", "--no-owner", "--no-comment", "--file", @filename, "my-app-db"], + [{}, "pg_dump", "--schema-only", "--no-privileges", "--no-owner", "--no-comments", "--file", @filename, "my-app-db"], returns: true ) do with_dump_schemas(:all) do @@ -474,7 +474,7 @@ if current_adapter?(:PostgreSQLAdapter) assert_called_with( Kernel, :system, - [{}, "pg_dump", "--schema-only", "--no-privileges", "--no-owner", "--no-comment", "--file", @filename, "--schema=foo", "--schema=bar", "my-app-db"], + [{}, "pg_dump", "--schema-only", "--no-privileges", "--no-owner", "--no-comments", "--file", @filename, "--schema=foo", "--schema=bar", "my-app-db"], returns: true ) do with_dump_schemas("foo,bar") do @@ -488,7 +488,7 @@ if current_adapter?(:PostgreSQLAdapter) assert_called_with( Kernel, :system, - [{}, "pg_dump", "--schema-only", "--no-privileges", "--no-owner", "--no-comment", "--file", filename, "my-app-db"], + [{}, "pg_dump", "--schema-only", "--no-privileges", "--no-owner", "--no-comments", "--file", filename, "my-app-db"], returns: nil ) do e = assert_raise(RuntimeError) do