Skip to content

Releases: vapor/postgres-nio

Fixes an issue where empty values were treated as null values and vica versa

26 Feb 10:49
fa93d76
Compare
Choose a tag to compare
This patch was authored by @fabianfett and released by @0xTim.

Fix encoding and decoding optional values to and from the database due to a regression in #135. Resolves #143 (#144)

Fixes an issue where empty values were treated as null values and vica versa

26 Feb 10:49
fa93d76
Compare
Choose a tag to compare
This patch was authored by @fabianfett and released by @0xTim.

Fix encoding and decoding optional values to and from the database due to a regression in #135. Resolves #143 (#144)

State machine

24 Feb 18:17
cdb18d1
Compare
Choose a tag to compare
This patch was authored by @fabianfett and released by @0xTim.

Motivation

Connection state changes can be modeled with state machines. This PR introduces a ConnectionStateMachine that models the PostgresConnection's state. This will improve the Unit-testability of this package.

Changes

  • This PR does not change any public API
  • It replaces the underlying implementation of PostgresConnection with a new PSQLConnection
  • All new classes and structs that support the new PSQLConnection live in the /New folder
  • The PSQLConnection is mainly implemented using these structs and classes:
    • PSQLFrontendMessage a new enum modeling outgoing client messages to the server
    • PSQLBackendMessage a new enum modeling incoming server messages to the client
    • PSQLFrontendMessage.Encoder a new MessageToByteEncoder
    • PSQLBackendMessage.Decoder a new ByteToMessageEncoder
    • ConnectionStateMachine with the sub state machines:
      • AuthenticationStateMachine
      • CloseStateMachine
      • ExtendedQueryStateMachine
      • PrepareStatementStateMachine
    • PSQLChannelHandler is the main ChannelDuplexHandler for the PSQLConnection
    • PSQLEventsHandler is a new ChannelHandler that observes the channel events and closes the connection when appropriate.
    • PSQLEncodable is a new protocol to convert Swift types to Postgres types.
    • PSQLDecodable is a new protocol to convert Postgres types to Swift types.
    • PSQLEncodable and PSQLDecodable defer the encoding and decoding as much as possible, saving unnecessary allocations and conversions.
  • Thanks to these changes extended queries and prepared statements will now take the same code paths. Thus we ensure that code improvements for one query type will also lead to improvements for the other.

Result

We get a better testable PostgresConnection.

State machine

24 Feb 18:17
cdb18d1
Compare
Choose a tag to compare
This patch was authored by @fabianfett and released by @0xTim.

Motivation

Connection state changes can be modeled with state machines. This PR introduces a ConnectionStateMachine that models the PostgresConnection's state. This will improve the Unit-testability of this package.

Changes

  • This PR does not change any public API
  • It replaces the underlying implementation of PostgresConnection with a new PSQLConnection
  • All new classes and structs that support the new PSQLConnection live in the /New folder
  • The PSQLConnection is mainly implemented using these structs and classes:
    • PSQLFrontendMessage a new enum modeling outgoing client messages to the server
    • PSQLBackendMessage a new enum modeling incoming server messages to the client
    • PSQLFrontendMessage.Encoder a new MessageToByteEncoder
    • PSQLBackendMessage.Decoder a new ByteToMessageEncoder
    • ConnectionStateMachine with the sub state machines:
      • AuthenticationStateMachine
      • CloseStateMachine
      • ExtendedQueryStateMachine
      • PrepareStatementStateMachine
    • PSQLChannelHandler is the main ChannelDuplexHandler for the PSQLConnection
    • PSQLEventsHandler is a new ChannelHandler that observes the channel events and closes the connection when appropriate.
    • PSQLEncodable is a new protocol to convert Swift types to Postgres types.
    • PSQLDecodable is a new protocol to convert Postgres types to Swift types.
    • PSQLEncodable and PSQLDecodable defer the encoding and decoding as much as possible, saving unnecessary allocations and conversions.
  • Thanks to these changes extended queries and prepared statements will now take the same code paths. Thus we ensure that code improvements for one query type will also lead to improvements for the other.

Result

We get a better testable PostgresConnection.

Make PostgresNIO tests non throwing

19 Feb 15:14
5876fdf
Compare
Choose a tag to compare
This patch was authored by @fabianfett and released by @0xTim.

Refactor all remaining PostgresNIO tests to get better error diagnostics in case of unexpected errors. (#141)

Follow up to #140.

Remove unintended SASL print statement

12 Feb 10:34
7c52814
Compare
Choose a tag to compare
This patch was authored by @fabianfett and released by @gwynne.

We currently print the internal SASL state when authenticating via SCRAM-SHA256. This messes up logs and is a potential security issue.

Modifications

  • Remove a print statement

Support for SCRAM-SHA-256 SASL authentication

11 Jan 01:41
072b685
Compare
Choose a tag to compare
This patch was authored and released by @gwynne.
  • PostgreSQL supports SCRAM-SHA-256 authentication since version 11. This is preliminary support for that authentication type.

Close connection if requestTLS fails

10 Dec 01:36
2808c4f
Compare
Choose a tag to compare
This patch was authored and released by @0xTim.

Correctly close the PostgreSQL connection if requestTLS fails.

Resolves #133

Support custom JSON coders

09 Sep 16:54
3cf2496
Compare
Choose a tag to compare
This patch was authored by @jordanebelanger and released by @tanner0101.

Add support for custom, non-Foundation, JSON encoder & decoder through global variables PostgresNIO._defaultJSONEncoder and PostgresNIO._defaultJSONDecoder (#125, fixes #126).

Fix prepare(query:) when no data returned

20 Aug 19:16
dddb196
Compare
Choose a tag to compare
This patch was authored by @Jerry-Carter and released by @tanner0101.

Fixes prepare(query:) when used with queries that return no results (like DELETE ...) (#123, fixes #122).