-
-
Notifications
You must be signed in to change notification settings - Fork 79
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
PSQLDecodingError improvements #211
Conversation
Codecov Report
@@ Coverage Diff @@
## main #211 +/- ##
==========================================
+ Coverage 40.70% 43.81% +3.10%
==========================================
Files 118 118
Lines 7706 7700 -6
==========================================
+ Hits 3137 3374 +237
+ Misses 4569 4326 -243
Flags with carried forward coverage won't be shown. Click here to find out more.
|
7d9cc1d
to
372c53d
Compare
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.
No actual serious changes need making, just want to be sure I'm clear on what's going on in a couple of spots before moving ahead.
8fa7dab
to
47b5921
Compare
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.
Looks g2g! 👍 ❤️
Split out to #209.
Motivation
Currently we hand a large
PSQLDecodingContext
into thePSQLDecodable
'sdecode
method. Lets look at it, as it is today:We use most of the
PSQLDecodingContext
's properties to create good error messages for users. Let's look at an implementation example:As we can see the
context
is only used to create errors. If library adopters want to implement decoding for their own types, they need to forward thecontext
as well, if they want to create good errors.However we, as the Postgres library authors, don't need to pass the decoding info to the users and expect them to return it to us.
All decoding metadata can be kept in our code. For this reason users should return a
PSQLDecodingError.Code
from the decode method and we can create a full PSQLDecodingError based on this information. This also reduces code size quite a bit.Changes
PSQLDecodingError.Code
fromPSQLDecodable
decode
function.PSQLData
as those don't work anyway.Optional
decoding to something actually working.Result