Skip to content
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

Remove PSQLJSONEncoder #215

Merged
merged 2 commits into from
Feb 17, 2022
Merged

Conversation

fabianfett
Copy link
Collaborator

@fabianfett fabianfett commented Feb 15, 2022

Motivation

While rewriting lot's of PostgresNIO internals in the last year, I created new types that very closely match existing types. This was a mistake. I should have tried everything to reuse existing types, and change them as needed.

Changes

⚠️ This PR extends API... minor version bump required.

  • Remove PSQLJSONEncoder
  • Extend PostgresJSONEncoder with an encode method based on ByteBuffer
  • Provide a default implementation for the new encode method based on ByteBuffer to not break API
  • Replace all uses of PSQLJSONEncoder with PostgresJSONEncoder

Result

Fewer types, easier API for adopters.

@codecov-commenter
Copy link

codecov-commenter commented Feb 15, 2022

Codecov Report

Merging #215 (47281a6) into main (eaef208) will increase coverage by 4.17%.
The diff coverage is 37.50%.

@@            Coverage Diff             @@
##             main     #215      +/-   ##
==========================================
+ Coverage   40.69%   44.87%   +4.17%     
==========================================
  Files         117      118       +1     
  Lines        7709     7713       +4     
==========================================
+ Hits         3137     3461     +324     
+ Misses       4572     4252     -320     
Flag Coverage Δ
unittests 44.87% <37.50%> (+4.17%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...resNIO/Connection/PostgresConnection+Connect.swift 0.00% <0.00%> (ø)
Sources/PostgresNIO/New/PSQLCodable.swift 100.00% <ø> (ø)
Sources/PostgresNIO/Postgres+PSQLCompat.swift 0.00% <ø> (ø)
...es/PostgresNIO/Utilities/PostgresJSONEncoder.swift 0.00% <0.00%> (ø)
Sources/PostgresNIO/New/Messages/Bind.swift 100.00% <100.00%> (ø)
Sources/PostgresNIO/New/PSQLConnection.swift 31.68% <100.00%> (+1.98%) ⬆️
...s/PostgresNIO/New/PSQLFrontendMessageEncoder.swift 100.00% <100.00%> (ø)
...urces/PostgresNIO/New/Data/Array+PSQLCodable.swift 94.68% <0.00%> (+1.06%) ⬆️
...rces/PostgresNIO/New/Extensions/Logging+PSQL.swift 19.60% <0.00%> (+1.42%) ⬆️
... and 25 more

@fabianfett fabianfett requested a review from 0xTim February 15, 2022 13:18
Copy link
Member

@gwynne gwynne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as #212 and #213, why are you wasting my time reading my approval instead of merging lovely code cleanups faster than I can thumbs-up 'em? 🙃

@fabianfett fabianfett force-pushed the ff-remove-psqljsonencoder branch from 895c853 to 183abef Compare February 17, 2022 18:27
@fabianfett fabianfett force-pushed the ff-remove-psqljsonencoder branch from 183abef to 47281a6 Compare February 17, 2022 19:47
@fabianfett fabianfett merged commit 7660f79 into vapor:main Feb 17, 2022
@fabianfett fabianfett deleted the ff-remove-psqljsonencoder branch February 17, 2022 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants