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: Revert inet to return as a string and handle values with net masks #1568
Conversation
FYI I copied the error message state codes from the existing function so it's set to |
Excellent. Thanks. I'm inclined to push this but am going to let it bake a bit to see if anyone else has any comments. |
❌ Build pgjdbc 1.0.446 failed (commit a63c12cb20 by @sehrope) |
Not sure what's up with the AppVeyor build. One out of four build configs failed but it's something unrelated to this PR: https://ci.appveyor.com/project/davecramer/pgjdbc/builds/27342998/job/b5394yla9yfc7aku#L479 |
❌ Build pgjdbc 1.0.446 failed (commit a63c12cb20 by @sehrope) |
@maffe Nice catch! Looks like that piece of the code is still in there: pgjdbc/pgjdbc/src/main/java/org/postgresql/jdbc/PgConnection.java Lines 554 to 561 in e9423dc
I bet it's not being called as that's the fallback when the more specific getXyz(...) methods cannot figure out what to return. I'm going to try removing it and the string handling to restore the original behavior. |
2ae8a79
to
9814662
Compare
Okay force pushed an update that reflects the actually prior behavior of returning a |
… net masks Reverts inet type columns to return their value as a PGObject rather than parsing them as InetAddress values. This ensures that the mask value is not lost. Also corrects the getObject(..., InetAddress.class) handling to split out the net mask and return only the address portion.
9814662
to
e2fd2ce
Compare
❌ Build pgjdbc 1.0.447 failed (commit 1c5a730cef by @sehrope) |
This actually works to our advantage in the case where we decide to return a custom object as it can always be cast to a PGObject. As long as we keep toString() the same we should be good. |
✅ Build pgjdbc 1.0.448 completed (commit 6007d8ef25 by @sehrope) |
Codecov Report
@@ Coverage Diff @@
## master #1568 +/- ##
==========================================
- Coverage 68.9% 65.2% -3.7%
+ Complexity 3972 3889 -83
==========================================
Files 179 179
Lines 16565 16943 +378
Branches 2695 2768 +73
==========================================
- Hits 11414 11048 -366
- Misses 3899 4610 +711
- Partials 1252 1285 +33 |
Anyone see any reason not to push this ? |
Reverts inet type columns to default to returning their value as the text representation returned by the backend rather than parsing them as InetAddress values. This ensures that the mask value is not lost.
Also corrects the getObject(..., InetAddress.class) handling to split out the net mask and return only the address portion.
I've also updated the tests for inet data types to clean it up a bit, explicitly test getString() / getObject(), and add some additional edge cases (ex: "10.20.30.40/32" gets round tripped by the server to strip out the /32).
When (if?) we change the default return type to give a PGInet that test should fail and need to be updated. As I tend to lean toward backwards compatibility, I think we should leave the default as a text and if anything provide PGInet as a separate class that anyone who wants can use. Could consider using something similar to handle mac data types too.
Closes #1567
See also #1134 for related discussion.
All Submissions:
New Feature Submissions:
Changes to Existing Features:
Yes. It reverts
inet
data type handling to return aString
instead ofInetAddress
by default.