pgjdbc/pgjdbc GitHub issues and pull requests (mirror)
help / color / mirror / Atom feedFrom: vlsi (@vlsi) <[email protected]>
To: pgjdbc/pgjdbc <[email protected]>
Subject: Re: [pgjdbc/pgjdbc] PR #3631: fix: isValid incorrectly called execute, instead of executeWithFlags fixes Issue #3630
Date: Tue, 13 May 2025 12:10:58 +0000
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
How about adding a check to `execute(String sql, int autoGeneratedKeys)` so it rejects unknown flags at least during pgjdbc test execution?
Here's the current code:
```java
/**
* ...
* @param autoGeneratedKeys a flag indicating whether auto-generated keys
* should be made available for retrieval;
* one of the following constants:
* {@code Statement.RETURN_GENERATED_KEYS}
* {@code Statement.NO_GENERATED_KEYS}
*/
@Override
public boolean execute(String sql, int autoGeneratedKeys) throws SQLException {
if (autoGeneratedKeys == Statement.NO_GENERATED_KEYS) {
return execute(sql);
}
return execute(sql, (String[]) null);
}
```
WDYT of adding a check there so it ensures `autoGeneratedKeys` must be either `RETURN_GENERATED_KEYS` or `NO_GENERATED_KEYS`?
Of course it is not backward-compatible, so it should be under `pgjdbc.asserts.statements=true` flag so we could enable it for our tests and the users could enable it to detect wrong API usage in their systems.
----
The test could be located in error-prone (see https://github.com/google/error-prone/issues/3684), or in `javac` itself. I guess it could be a valid `javac` warning if the code casts the object, and then calls the method which was avaliable without a cast.
view thread (15+ 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 #3631: fix: isValid incorrectly called execute, instead of executeWithFlags fixes Issue #3630
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