Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ruby 3.3 / remove ruby 3.0 and pg 11 from build matrix #97

Merged
merged 1 commit into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,15 @@ jobs:
strategy:
matrix:
pg:
- 11
- 12
- 13
- 14
- 15
- 16
ruby:
- "3.0"
- "3.1"
- "3.2"
- "3.3"
gemfile:
- rails_6.1
- rails_7.0
Expand Down
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ruby-3.0
ruby-3.3.0
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ The following functionality is currently unsupported:

Compatibility notes:

- While some features may work with other versions, this gem is currently tested against PostgreSQL 11+ and Partman 4.x
- While some features may work with other versions, this gem is currently tested against PostgreSQL 12+ and Partman 4.x
- There is a [bug](https://github.com/rails/rails/pull/41490) in early versions of Rails 6.1 when using `algorithm: :concurrently`. To add / remove indexes concurrently, please upgrade to at least Rails 6.1.4.

#### safe\_create\_table
Expand Down
52 changes: 17 additions & 35 deletions spec/safe_statements_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ def up
end

[:string, :text, :enum, :binary].each do |type|
it "allows a default value that looks like an expression for the #{type.inspect} type on Postgres 11+" do
it "allows a default value that looks like an expression for the #{type.inspect} type" do
migration = Class.new(migration_klass) do
define_method(:up) do
unsafe_create_table :foos
Expand All @@ -670,20 +670,14 @@ def up
end
end

if ActiveRecord::Base.connection.postgresql_version >= 11_00_00
migration.suppress_messages { migration.migrate(:up) }
migration.suppress_messages { migration.migrate(:up) }

# Handle binary columns being transported, but not stored, as hex.
expected_value = type == :binary ? "\\x4e4f572829" : "NOW()"
expect(ActiveRecord::Base.connection.columns("foos").detect { |column| column.name == "bar" }.default).to eq(expected_value)
# Handle binary columns being transported, but not stored, as hex.
expected_value = type == :binary ? "\\x4e4f572829" : "NOW()"
expect(ActiveRecord::Base.connection.columns("foos").detect { |column| column.name == "bar" }.default).to eq(expected_value)

ActiveRecord::Base.connection.execute("INSERT INTO foos DEFAULT VALUES")
expect(ActiveRecord::Base.connection.select_values("SELECT bar FROM foos")).to all(eq(expected_value))
else
expect do
migration.suppress_messages { migration.migrate(:up) }
end.to raise_error PgHaMigrations::UnsafeMigrationError
end
ActiveRecord::Base.connection.execute("INSERT INTO foos DEFAULT VALUES")
expect(ActiveRecord::Base.connection.select_values("SELECT bar FROM foos")).to all(eq(expected_value))
end
end

Expand Down Expand Up @@ -713,7 +707,7 @@ def up
end.to raise_error PgHaMigrations::UnsafeMigrationError
end

it "allows setting null => false (with a default) on Postgres 11+ and forbids it otherwise" do
it "allows setting null => false (with a default)" do
migration = Class.new(migration_klass) do
def up
unsafe_create_table :foos
Expand All @@ -722,16 +716,10 @@ def up
end
end

if ActiveRecord::Base.connection.postgresql_version >= 11_00_00
migration.suppress_messages { migration.migrate(:up) }
aggregate_failures do
expect(ActiveRecord::Base.connection.select_value("SELECT bar FROM foos")).to eq("baz")
expect(ActiveRecord::Base.connection.columns("foos").detect { |column| column.name == "bar" }.null).to eq(false)
end
else
expect do
migration.suppress_messages { migration.migrate(:up) }
end.to raise_error PgHaMigrations::UnsafeMigrationError
migration.suppress_messages { migration.migrate(:up) }
aggregate_failures do
expect(ActiveRecord::Base.connection.select_value("SELECT bar FROM foos")).to eq("baz")
expect(ActiveRecord::Base.connection.columns("foos").detect { |column| column.name == "bar" }.null).to eq(false)
end
end

Expand Down Expand Up @@ -1018,7 +1006,7 @@ def up
end

describe "when not configured to disallow two-step new column and adding default" do
it "allows setting a constant default value on Postgres 11+ when the column was added in the same migration" do
it "allows setting a constant default value when the column was added in the same migration" do
migration = Class.new(migration_klass) do
define_method(:up) do
unsafe_create_table :foos
Expand All @@ -1040,7 +1028,7 @@ def up
.and_return(true)
end

it "disallows setting a constant default value on Postgres 11+ when the column was added in the same migration" do
it "disallows setting a constant default value when the column was added in the same migration" do
migration = Class.new(migration_klass) do
define_method(:up) do
unsafe_create_table :foos
Expand All @@ -1049,15 +1037,9 @@ def up
end
end

if ActiveRecord::Base.connection.postgresql_version >= 11_00_00
expect do
migration.suppress_messages { migration.migrate(:up) }
end.to raise_error PgHaMigrations::BestPracticeError
else
expect do
migration.suppress_messages { migration.migrate(:up) }
end.not_to raise_error
end
expect do
migration.suppress_messages { migration.migrate(:up) }
end.to raise_error PgHaMigrations::BestPracticeError
end
end
end
Expand Down
Loading