Remove use of Row#getAnyOption from FinaglePostgresDecoders#1848
Merged
juliano merged 2 commits intoMay 20, 2020
Conversation
This addresses a part of the cause of issue [zio#1844](zio#1844) which is that the decoders that are not direct in `FinaglePostgresDecoders` rely on `Row#getAnyOption`. `Row#getAnyOption` relies on custom receiving functions being defined on the `PostgresClient`. postgres-finagle could define these by default (which it probably should), but by default it does not. When custom receiving functions are not defined, `Row#getAnyOption` always returns `None`. This change introduces an `orElse` method on `FinaglePostgresDecoder` which allows for composition of `ValueDecoder`s that was previous being accomplished by `PartialFunction`s. This solution removes the need for `ClassTag` (although we may want to keep it to keep error messages consistent) as well as the reliance on `Row#getAnyOption`. It also removes the definition of `decoder[T]`.
This file contains hidden or 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
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.
Fixes #1844
Problem
The decoders that are not direct in
FinaglePostgresDecodersrely onRow#getAnyOption.Row#getAnyOptionrelies on custom receiving functions being defined on thePostgresClient. postgres-finagle could define these by default (which it probably should), but by default it does not. When custom receiving functions are not defined,Row#getAnyOptionalways returnsNone.Solution
This change introduces an
orElsemethod onFinaglePostgresDecoderwhich allows for composition ofValueDecoders that was previous being accomplished byPartialFunctions. This solution removes the need forClassTag(although we may want to keep it to keep error messages consistent) as well as the reliance onRow#getAnyOption.Notes
This removes the definition of
decoder[T]which I do not see much value in since it requires custom receive functions to be defined forTin order to work.Checklist
README.mdif applicable[WIP]to the pull request title if it's work in progresssbt scalariformFormat test:scalariformFormatto make sure that the source files are formatted@getquill/maintainers