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
fix: setNull for types not in java.sql.Types (e.g. uuid) #1160
Conversation
@davecramer , apparently this is a bug:
It should be |
@vlsi the bug is the test, not the code, correct ? |
right you are |
preparedParameters.setNull(parameterIndex, oid); | ||
|
||
} else { | ||
setNull(parameterIndex, t); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you please rephrase as follows?
if (typeName == null) {
setNull(parameterIndex, t);
return;
}
checkClosed();
...
pstmt.setNull(3, Types.OTHER, "uuid"); | ||
ResultSet rs = pstmt.executeQuery(); | ||
|
||
while (rs.next()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The statement should return rows, so please add an assertion (to ensure nulls are passed properly).
I was expecting to see this issue fixed in release 42.2.3, but it still open. |
Apparently CI check fails, so it is not mergeable. I don't think @davecramer works on this at the moment, so you can pick it up. PS. The ticket/PR was not marked for 42.2.3 milestone, so I have not checked it before pushing 42.2.3 |
I was pretty sure that it would be contained in 42.2.3 milestone (and was really looking forward to ti) so I didn't check with the project project. |
@raubel are you going to work on fixing the tests? |
@davecramer, not right now and not sure it'd be very efficient. |
So it only fails in 8.2 I'm inclined to ignore that version for this PR |
Codecov Report
@@ Coverage Diff @@
## master #1160 +/- ##
============================================
- Coverage 68.69% 68.68% -0.02%
- Complexity 3848 3849 +1
============================================
Files 174 174
Lines 16035 16042 +7
Branches 2614 2615 +1
============================================
+ Hits 11016 11019 +3
- Misses 3781 3784 +3
- Partials 1238 1239 +1 |
public void setNull(int i, int t, String s) throws SQLException { | ||
public void setNull(int parameterIndex, int t, String typeName) throws SQLException { | ||
|
||
if ( typeName == null ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you please trim spaces around typeName == null
?
@@ -560,7 +560,7 @@ public void testToString() throws SQLException { | |||
public void nullArray() throws SQLException { | |||
PreparedStatement ps = con.prepareStatement("INSERT INTO arrtest(floatarr) VALUES (?)"); | |||
|
|||
ps.setNull(1, Types.ARRAY, "float8"); | |||
ps.setNull(1, Types.ARRAY, "float8[]"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an interesting side effect. I think it is worth including in a notable changes. So clients get prepared for "unexpected" operation of setNull (since String argument has been just ignored for ages)
Thank you both for your work :-) |
Implement public void setNull(int parameterIndex, int t, String s)
Fixes #1159