Skip to content

Updated to use new PostgresKit/PostgresNIO APIs

Compare
Choose a tag to compare
@VaporBot VaporBot released this 09 May 16:01
· 10 commits to main since this release
8817a61
This patch was authored and released by @gwynne.

PostgresKit 2.11.0 heavily revamped PostgresKit to take full (or near to it) advantage of the modern PostgresNIO APIs. These changes do the same for FluentPostgresDriver, including adopting the revisions made to PostgresKit's API. This incidentally results in a significant improvement in the layering of the three packages, with FluentPostgresDriver now relying almost entirely on PostgresKit alone rather than needing to separately know details of PostgresNIO (with one or two exceptions). The end result is much cleaner code and moderate performance improvements.

Swift 5.7 or later is now required.

Users who previously specified custom PostgresDataEncoder and/or PostgresDataDecoder instances in their database configurations will begin receiving deprecation warnings; the replacements are PostgresNIO's PostgresEncodingContext and PostgresDecodingContext:

let postgresEncoder = PostgresDataEncoder(json: JSONEncoder()) // deprecated
let postgresEncodingContext = PostgresEncodingContext(jsonEncoder: JSONEncoder()) // new

let defaultPostgresEncoder = PostgresDataEncoder() // deprecated
let defaultPostgresEncodingContext = PostgresEncodingContext.default // new

let postgresDecoder = PostgresDataDecoder(json: JSONDecoder()) // deprecated
let postgresDecodingContext = PostgresDecodingContext(jsonDecoder: JSONDecoder()) // new

let defaultPostgresDecoder = PostgresDataDecoder() // deprecated
let defaultPostgresDecodingContext = PostgresDecodingContext.default // new