Skip to content
Draft
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
16 changes: 11 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,23 @@ on:

jobs:
tests:
name: Ruby ${{ matrix.ruby }}, Rails ${{ matrix.rails }}
name: "${{ matrix.ruby }} / rails ${{ matrix.rails }} / postgres ${{ matrix.database.version }}"
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
ruby: ["3.2", "3.3", "3.4", "4.0"]
rails: ["7.2", "8.0", "8.1"]
ruby: ["ruby-3.2", "ruby-4.0"]
rails: ["7.2", "8.1"]
database:
- image: "postgres"
version: "14"
- image: "postgres"
version: "18"

services:
postgres:
image: postgres:14
image: ${{ matrix.database.image }}:${{ matrix.database.version }}
env:
POSTGRES_USER: postgres
POSTGRES_HOST_AUTH_METHOD: trust
Expand All @@ -34,9 +39,10 @@ jobs:

env:
POSTGRES_USER: postgres
RAILS_VERSION: ${{ matrix.rails }}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v6

- name: Set up Ruby
uses: ruby/setup-ruby@v1
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ changelog, see the [commits] for each version via the version links.

[Unreleased]: https://github.com/teoljungberg/fx/compare/v0.10.0..HEAD

- Add PostgreSQL versioning policy (#180)
- Officially support PostgreSQL 14, 15, 16, 17, 18
- Follow PostgreSQL's 5-year support window
- Add PostgreSQL 18 to CI test matrix
- Document policy in README and gemspec metadata

## [0.10.0]

[0.10.0]: https://github.com/teoljungberg/fx/compare/v0.9.0...v0.10.0
Expand Down
5 changes: 5 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
source "https://rubygems.org"

rails_version = ENV.fetch("RAILS_VERSION", "8.1")

gemspec

gem "activerecord", "~> #{rails_version}.0"
gem "railties", "~> #{rails_version}.0"

gem "bundler", ">= 1.5"
gem "pg"
gem "pry"
Expand Down
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,19 @@ column value instead of a plain string.
- [Oracle](https://github.com/zygotecnologia/fx-oracle-adapter)
- [SQLserver](https://github.com/tarellel/fx-sqlserver-adapter)

## PostgreSQL Version Support

F(x) follows [PostgreSQL's versioning policy], supporting all major versions
within their 5-year support window.

**Currently supported:** PostgreSQL 14, 15, 16, 17, 18

When a PostgreSQL version reaches end-of-life, support will be dropped in the
next minor release of F(x). Older versions may continue to work but are not
tested or guaranteed.

[PostgreSQL's versioning policy]: https://www.postgresql.org/support/versioning/

## Contributing

See [contributing](CONTRIBUTING.md) for more details.
3 changes: 2 additions & 1 deletion fx.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ Gem::Specification.new do |spec|
"bug_tracker_uri" => "#{spec.homepage}/issues",
"changelog_uri" => "#{spec.homepage}/blob/v#{spec.version}/CHANGELOG.md",
"homepage_uri" => spec.homepage,
"source_code_uri" => spec.homepage
"source_code_uri" => spec.homepage,
"postgresql_versions" => "14, 15, 16, 17, 18"
}

spec.files = `git ls-files -z`.split("\x0")
Expand Down
30 changes: 26 additions & 4 deletions lib/fx/adapters/postgres/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,39 @@ class Postgres
#
# @api private
class Connection < SimpleDelegator
# PostgreSQL version constants for feature support
# PostgreSQL version constants for feature support.
#
# F(x) follows PostgreSQL's versioning policy, supporting all major
# versions within their 5-year support window.
# See: https://www.postgresql.org/support/versioning/
#
# Version format: XXYYZZ where XX=major, YY=minor, ZZ=patch
# Example: 14_00_00 = PostgreSQL 14.0.0
POSTGRES_VERSIONS = {
# PostgreSQL 10.0 - introduced DROP FUNCTION without args
# https://www.postgresql.org/docs/10/sql-dropfunction.html
v10: 10_00_00
v10: 10_00_00, # DROP FUNCTION without args support
v14: 14_00_00, # Minimum supported version
v15: 15_00_00,
v16: 16_00_00,
v17: 17_00_00,
v18: 18_00_00 # Latest supported version
}.freeze

# The minimum PostgreSQL version officially supported by F(x).
# Versions below this may work but are not tested or guaranteed.
MINIMUM_SUPPORTED_VERSION = :v14
private_constant :MINIMUM_SUPPORTED_VERSION

def support_drop_function_without_args
server_version >= POSTGRES_VERSIONS[:v10]
end

# Returns true if the connected PostgreSQL version is officially supported.
#
# @return [Boolean]
def supported_postgres_version?
server_version >= POSTGRES_VERSIONS[MINIMUM_SUPPORTED_VERSION]
end

private

def server_version
Expand Down
42 changes: 42 additions & 0 deletions spec/fx/adapters/postgres_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -183,4 +183,46 @@
expect(result).to be(false)
end
end

describe "#supported_postgres_version?" do
it "returns true for PostgreSQL 14 (minimum supported)" do
adapter = Fx::Adapters::Postgres.new
connection = adapter.send(:connection)
allow(connection).to receive(:server_version).and_return(14_00_00)

result = connection.supported_postgres_version?

expect(result).to be(true)
end

it "returns true for PostgreSQL 18 (latest supported)" do
adapter = Fx::Adapters::Postgres.new
connection = adapter.send(:connection)
allow(connection).to receive(:server_version).and_return(18_00_00)

result = connection.supported_postgres_version?

expect(result).to be(true)
end

it "returns false for PostgreSQL 13 (EOL)" do
adapter = Fx::Adapters::Postgres.new
connection = adapter.send(:connection)
allow(connection).to receive(:server_version).and_return(13_00_00)

result = connection.supported_postgres_version?

expect(result).to be(false)
end

it "returns false for PostgreSQL 10" do
adapter = Fx::Adapters::Postgres.new
connection = adapter.send(:connection)
allow(connection).to receive(:server_version).and_return(10_00_00)

result = connection.supported_postgres_version?

expect(result).to be(false)
end
end
end