diff --git a/Gemfile.lock b/Gemfile.lock index c419a75..94a2284 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - activerecord-pg-extensions (0.5.2) + activerecord-pg-extensions (0.5.3) activerecord (~> 7.0.0) railties (~> 7.0.0) @@ -157,4 +157,4 @@ DEPENDENCIES rubocop-rspec (~> 2.3) BUNDLED WITH - 2.2.17 + 2.4.19 diff --git a/gemfiles/rails_7.0.gemfile.lock b/gemfiles/rails_7.0.gemfile.lock index 6a091bc..ab84a4e 100644 --- a/gemfiles/rails_7.0.gemfile.lock +++ b/gemfiles/rails_7.0.gemfile.lock @@ -1,7 +1,7 @@ PATH remote: .. specs: - activerecord-pg-extensions (0.5.1) + activerecord-pg-extensions (0.5.3) activerecord (~> 7.0.0) railties (~> 7.0.0) diff --git a/lib/active_record/pg_extensions/postgresql_adapter.rb b/lib/active_record/pg_extensions/postgresql_adapter.rb index 551cbb9..17651ae 100644 --- a/lib/active_record/pg_extensions/postgresql_adapter.rb +++ b/lib/active_record/pg_extensions/postgresql_adapter.rb @@ -10,7 +10,7 @@ module PostgreSQLAdapter # see https://www.postgresql.org/docs/current/sql-set-constraints.html def set_constraints(deferred, *constraints) raise ArgumentError, "deferred must be :deferred or :immediate" unless %i[deferred - immediate].include?(deferred) + immediate].include?(deferred.to_sym) constraints = constraints.map { |c| quote_table_name(c) }.join(", ") constraints = "ALL" if constraints.empty? diff --git a/lib/active_record/pg_extensions/version.rb b/lib/active_record/pg_extensions/version.rb index 62a34d8..5c46ac2 100644 --- a/lib/active_record/pg_extensions/version.rb +++ b/lib/active_record/pg_extensions/version.rb @@ -2,6 +2,6 @@ module ActiveRecord module PGExtensions - VERSION = "0.5.2" + VERSION = "0.5.3" end end diff --git a/spec/postgresql_adapter_spec.rb b/spec/postgresql_adapter_spec.rb index 07c6cab..5c44bc1 100644 --- a/spec/postgresql_adapter_spec.rb +++ b/spec/postgresql_adapter_spec.rb @@ -14,6 +14,11 @@ expect { connection.set_constraints("garbage") }.to raise_error(ArgumentError) end + it "allows string arguments" do + expect { connection.set_constraints("deferred") }.not_to raise_error(ArgumentError) + expect { connection.set_constraints("immediate") }.not_to raise_error(ArgumentError) + end + it "defaults to all" do connection.set_constraints(:deferred) expect(connection.executed_statements).to eq ["SET CONSTRAINTS ALL DEFERRED"]