pgjdbc/pgjdbc GitHub issues and pull requests (mirror)  
help / color / mirror / Atom feed
From: sehrope (@sehrope) <[email protected]>
To: pgjdbc/pgjdbc <[email protected]>
Subject: [pgjdbc/pgjdbc] PR #3939: Add RequireServerVersion annotation for tests
Date: Sat, 14 Feb 2026 18:35:05 +0000
Message-ID: <[email protected]> (raw)

Three commits here which:

* Add a new `@RequireServerVersion` annotation for tests that allows declaring the applicable server versions.
* Replaces the `@DisabledIfServerVersionBelow` and `@DisabledIfServerVersionGreater` usage with `@RequireServerVersion`
* Removes the unused annotations

Main driver for this was trying to understand which test is running when. The double negative for the annotation vs the check makes it confusing (e.g., it runs when it's not disabled and that is driven by the version being below...).

It's also ambiguous if something like "*Greater than 10*" really means greater than or equal 10.0.

The new approach positive affirms the situations where we want the thing to run with annotation args for:

* `lt` - Less than
* `lte` - Less than or equal
* `gt` - Greater than
* `gte` - Greater than or equal

I'd expect that `lt` and `gte` are going to be the most useful. The "less than" makes sense if you want all versions older than X (where presumably it breaks). And "greater than or equal" makes sense when X is the first version that supports a given feature that is being tested. Ex:

```diff
@@ -297,7 +297,7 @@ class LogicalReplicationStatusTest {
    * Test fail on PG version 9.4.5 because postgresql have bug.
    */
   @Test
-  @DisabledIfServerVersionBelow("9.4.8")
+  @RequireServerVersion(gte = "9.4.8")
   void applyLocationDoNotDependOnFlushLocation() throws Exception {
     PGConnection pgConnection = (PGConnection) replicationConnection;
```

Note that the old `@DisabledIfServerVersionGreater("19")` name implied a `>` check, but its implementation actually used `>=`, disabling the test for version 19 and above. The migration to `@RequireServerVersion(lt = "19")` preserves that existing runtime behavior while making the boundary semantics explicit.

One minor improvement to the old approach was caching the server response in the junit context. That shaves a connection open / close per annotation call. I doubt it's meaningfully different (24 uses of the annotation times 10ms per connection rounds to nothing) but nice to have an example of that in the test code. It may be useful somewhere else too.

view thread (16+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: github://pgjdbc/pgjdbc
  Cc: [email protected], [email protected]
  Subject: Re: [pgjdbc/pgjdbc] PR #3939: Add RequireServerVersion annotation for tests
  In-Reply-To: <<[email protected]>>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox