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

Cleanup encoding and decoding #230

Merged
merged 1 commit into from
Feb 25, 2022

Conversation

fabianfett
Copy link
Collaborator

Motivation

Simple code is better.

We have an escape hatch to implement the encoding of optionals on PostgresEncodable. However with the introduction of PostgresBindings, we can deal with this special case directly. Sadly this is not possible for Decoding. However we can improve the usability of the PostgresDecodable protocol, by prefixing the special values with an underscore.

Changes

  • Rename decodeRaw on PostgresDecodable to _decodeRaw
  • Rename DecodableType on PostgresDecodable to _DecodableType
  • Remove Optional conformance to PostgresEncodable

Result

Less and easier code.

# Conflicts:
#	Sources/PostgresNIO/Connection/PostgresConnection+Database.swift
#	Sources/PostgresNIO/New/Data/Optional+PostgresCodable.swift
#	Sources/PostgresNIO/New/PostgresCodable.swift
#	Sources/PostgresNIO/New/PostgresQuery.swift
#	Sources/PostgresNIO/Postgres+PSQLCompat.swift
#	Tests/PostgresNIOTests/New/Data/Optional+PSQLCodableTests.swift
@fabianfett fabianfett force-pushed the ff-cleanup-encoding-and-decoding branch from 04501db to 8084984 Compare February 25, 2022 17:53
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.

You're going for a 100% approval record, aren't you, Fabian? 🙂

I can't wait to start seeing some before and after performance numbers on this code!

@fabianfett fabianfett merged commit c493f0e into vapor:main Feb 25, 2022
@fabianfett fabianfett deleted the ff-cleanup-encoding-and-decoding branch March 13, 2022 15:47
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.

2 participants