From f435c371be5574006768425ac1a21b04e5dffe42 Mon Sep 17 00:00:00 2001 From: Guilherme Souza Date: Sat, 3 Aug 2024 08:15:01 -0300 Subject: [PATCH] feat(postgrest)!: remove deprecated code (#488) --- Sources/PostgREST/Deprecated.swift | 80 ------------------- .../PostgREST/PostgrestFilterBuilder.swift | 53 +----------- Sources/PostgREST/PostgrestQueryBuilder.swift | 2 +- Sources/PostgREST/PostgrestRpcBuilder.swift | 2 +- .../PostgREST/PostgrestTransformBuilder.swift | 2 +- 5 files changed, 4 insertions(+), 135 deletions(-) delete mode 100644 Sources/PostgREST/Deprecated.swift diff --git a/Sources/PostgREST/Deprecated.swift b/Sources/PostgREST/Deprecated.swift deleted file mode 100644 index d2ffb46b..00000000 --- a/Sources/PostgREST/Deprecated.swift +++ /dev/null @@ -1,80 +0,0 @@ -// -// Deprecated.swift -// -// -// Created by Guilherme Souza on 16/01/24. -// - -import Foundation - -#if canImport(FoundationNetworking) - import FoundationNetworking -#endif - -extension PostgrestClient.Configuration { - /// Initializes a new configuration for the PostgREST client. - /// - Parameters: - /// - url: The URL of the PostgREST server. - /// - schema: The schema to use. - /// - headers: The headers to include in requests. - /// - fetch: The fetch handler to use for requests. - /// - encoder: The JSONEncoder to use for encoding. - /// - decoder: The JSONDecoder to use for decoding. - @available( - *, - deprecated, - message: "Replace usages of this initializer with new init(url:schema:headers:logger:fetch:encoder:decoder:)" - ) - public init( - url: URL, - schema: String? = nil, - headers: [String: String] = [:], - fetch: @escaping PostgrestClient.FetchHandler = { try await URLSession.shared.data(for: $0) }, - encoder: JSONEncoder = PostgrestClient.Configuration.jsonEncoder, - decoder: JSONDecoder = PostgrestClient.Configuration.jsonDecoder - ) { - self.init( - url: url, - schema: schema, - headers: headers, - logger: nil, - fetch: fetch, - encoder: encoder, - decoder: decoder - ) - } -} - -extension PostgrestClient { - /// Creates a PostgREST client with the specified parameters. - /// - Parameters: - /// - url: The URL of the PostgREST server. - /// - schema: The schema to use. - /// - headers: The headers to include in requests. - /// - session: The URLSession to use for requests. - /// - encoder: The JSONEncoder to use for encoding. - /// - decoder: The JSONDecoder to use for decoding. - @available( - *, - deprecated, - message: "Replace usages of this initializer with new init(url:schema:headers:logger:fetch:encoder:decoder:)" - ) - public convenience init( - url: URL, - schema: String? = nil, - headers: [String: String] = [:], - fetch: @escaping FetchHandler = { try await URLSession.shared.data(for: $0) }, - encoder: JSONEncoder = PostgrestClient.Configuration.jsonEncoder, - decoder: JSONDecoder = PostgrestClient.Configuration.jsonDecoder - ) { - self.init( - url: url, - schema: schema, - headers: headers, - logger: nil, - fetch: fetch, - encoder: encoder, - decoder: decoder - ) - } -} diff --git a/Sources/PostgREST/PostgrestFilterBuilder.swift b/Sources/PostgREST/PostgrestFilterBuilder.swift index 46ab0696..3df84012 100644 --- a/Sources/PostgREST/PostgrestFilterBuilder.swift +++ b/Sources/PostgREST/PostgrestFilterBuilder.swift @@ -1,7 +1,7 @@ import Foundation import Helpers -public class PostgrestFilterBuilder: PostgrestTransformBuilder { +public class PostgrestFilterBuilder: PostgrestTransformBuilder, @unchecked Sendable { public enum Operator: String, CaseIterable, Sendable { case eq, neq, gt, gte, lt, lte, like, ilike, `is`, `in`, cs, cd, sl, sr, nxl, nxr, adj, ov, fts, plfts, phfts, wfts @@ -472,33 +472,6 @@ public class PostgrestFilterBuilder: PostgrestTransformBuilder { textSearch(column, query: query, config: config, type: nil) } - @available(*, deprecated, message: "Use textSearch(_:query:config:type) with .plain type.") - public func plfts( - _ column: String, - query: any URLQueryRepresentable, - config: String? = nil - ) -> PostgrestFilterBuilder { - textSearch(column, query: query, config: config, type: .plain) - } - - @available(*, deprecated, message: "Use textSearch(_:query:config:type) with .phrase type.") - public func phfts( - _ column: String, - query: any URLQueryRepresentable, - config: String? = nil - ) -> PostgrestFilterBuilder { - textSearch(column, query: query, config: config, type: .phrase) - } - - @available(*, deprecated, message: "Use textSearch(_:query:config:type) with .websearch type.") - public func wfts( - _ column: String, - query: any URLQueryRepresentable, - config: String? = nil - ) -> PostgrestFilterBuilder { - textSearch(column, query: query, config: config, type: .websearch) - } - /// Match only rows which satisfy the filter. This is an escape hatch - you should use the specific filter methods wherever possible. /// /// Unlike most filters, `opearator` and `value` are used as-is and need to follow [PostgREST syntax](https://postgrest.org/en/stable/api.html#operators). You also need to make sure they are properly sanitized. @@ -618,28 +591,4 @@ public class PostgrestFilterBuilder: PostgrestTransformBuilder { ) -> PostgrestFilterBuilder { fts(column, query: query, config: config) } - - public func plainToFullTextSearch( - _ column: String, - query: String, - config: String? = nil - ) -> PostgrestFilterBuilder { - plfts(column, query: query, config: config) - } - - public func phraseToFullTextSearch( - _ column: String, - query: String, - config: String? = nil - ) -> PostgrestFilterBuilder { - phfts(column, query: query, config: config) - } - - public func webFullTextSearch( - _ column: String, - query: String, - config: String? = nil - ) -> PostgrestFilterBuilder { - wfts(column, query: query, config: config) - } } diff --git a/Sources/PostgREST/PostgrestQueryBuilder.swift b/Sources/PostgREST/PostgrestQueryBuilder.swift index ac9a4e54..c738075d 100644 --- a/Sources/PostgREST/PostgrestQueryBuilder.swift +++ b/Sources/PostgREST/PostgrestQueryBuilder.swift @@ -1,7 +1,7 @@ import Foundation import Helpers -public final class PostgrestQueryBuilder: PostgrestBuilder { +public final class PostgrestQueryBuilder: PostgrestBuilder, @unchecked Sendable { /// Perform a SELECT query on the table or view. /// - Parameters: /// - columns: The columns to retrieve, separated by commas. Columns can be renamed when returned with `customName:columnName` diff --git a/Sources/PostgREST/PostgrestRpcBuilder.swift b/Sources/PostgREST/PostgrestRpcBuilder.swift index 08d3fa8b..4364b0b9 100644 --- a/Sources/PostgREST/PostgrestRpcBuilder.swift +++ b/Sources/PostgREST/PostgrestRpcBuilder.swift @@ -3,7 +3,7 @@ import Helpers struct NoParams: Encodable {} -public final class PostgrestRpcBuilder: PostgrestBuilder { +public final class PostgrestRpcBuilder: PostgrestBuilder, @unchecked Sendable { /// Performs a function call with parameters. /// - Parameters: /// - params: The parameters to pass to the function. diff --git a/Sources/PostgREST/PostgrestTransformBuilder.swift b/Sources/PostgREST/PostgrestTransformBuilder.swift index 45c83c5c..a0813400 100644 --- a/Sources/PostgREST/PostgrestTransformBuilder.swift +++ b/Sources/PostgREST/PostgrestTransformBuilder.swift @@ -1,7 +1,7 @@ import Foundation import Helpers -public class PostgrestTransformBuilder: PostgrestBuilder { +public class PostgrestTransformBuilder: PostgrestBuilder, @unchecked Sendable { /// Perform a SELECT on the query result. /// /// By default, `.insert()`, `.update()`, `.upsert()`, and `.delete()` do not return modified rows. By calling this method, modified rows are returned in `value`.