-
Notifications
You must be signed in to change notification settings - Fork 44
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
Support NULL value replacement for custom types #58
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nikicc
approved these changes
Feb 15, 2024
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.
Code changes make sense to me 👍 Thanks for fixing my bugs 🙈
Pull Request Test Coverage Report for Build 7958280161Details
💛 - Coveralls |
pilagod
reviewed
Feb 16, 2024
zitnik
force-pushed
the
customtype-nil-replacement
branch
from
February 16, 2024 11:07
82daeea
to
f40e445
Compare
pilagod
reviewed
Feb 17, 2024
pilagod
reviewed
Feb 19, 2024
Co-authored-by: Cyan Ho <pilagooood@gmail.com>
pilagod
approved these changes
Feb 20, 2024
Imported the new version to our project, seems to do the trick 🙂 @pilagod thank you for the review and for maintaining the library 💪 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR aims to add support for NULL value replacement in custom types. Builds upon #39 and #44.
Current issue
The issue that I came across with the current implementation is that when the pagination cursor includes
null
for a custom type, that value is not properly replaced with theNullReplacement
value. The reason is that the Go-representation of the cursor value is not nil, but a custom type object (with an underlying value of nil).This in turn causes the pagination WHERE clause to compare the COALESCEd values of the target column with an unreplaced NULL, e.g.
WHERE COALESCE(my_attr, '') > NULL
.Implementation
The change in this PR specifically handles custom types in the
isNil
function so that for custom types we evaluateisNil
on the underlying value retrieved byGetCustomTypeValue
instead of on the object itself.Test
In order to construct a test, I added a custom type as an alias of
sql.NullString
, implemented the necessary methods on this type, and added a new field to theorder
struct. I guess this is a bit clumsy, in case you have any ideas about how to construct such a test more compactly, please let me know :)In the test itself, we have a primary pagination rule on "Remark" and a secondary rule on the new "Description" field so that the NULL element (ID 2) appears in the cursor causing the described problem.