Skip to content

Commit

Permalink
fix(postgrest): update parameter of is filter to allow only Bool
Browse files Browse the repository at this point in the history
…or `nil` (#382)
  • Loading branch information
grdsdev authored May 13, 2024
1 parent 625ef8b commit 4ba1c7a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
18 changes: 9 additions & 9 deletions Sources/Auth/AuthClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -699,21 +699,21 @@ public final class AuthClient: Sendable {
/// - Parameter scope: Specifies which sessions should be logged out.
public func signOut(scope: SignOutScope = .global) async throws {
guard let accessToken = currentSession?.accessToken else {
configuration.logger?.warning("signOut called without a session")
return
configuration.logger?.warning("signOut called without a session")
return
}

if scope != .others {
await sessionManager.remove()
eventEmitter.emit(.signedOut, session: nil)
await sessionManager.remove()
eventEmitter.emit(.signedOut, session: nil)
}

do {
_ = try await api.execute(
.init(
url: configuration.url.appendingPathComponent("logout"),
method: .post,
query: [URLQueryItem(name: "scope", value: scope.rawValue)],
query: [URLQueryItem(name: "scope", value: scope.rawValue)],
headers: [.init(name: "Authorization", value: "Bearer \(accessToken)")]
)
)
Expand Down Expand Up @@ -936,10 +936,10 @@ public final class AuthClient: Sendable {
url: configuration.url.appendingPathComponent("user"),
method: .put,
query: [
(redirectTo ?? configuration.redirectToURL).map { URLQueryItem(
name: "redirect_to",
value: $0.absoluteString
) },
(redirectTo ?? configuration.redirectToURL).map { URLQueryItem(
name: "redirect_to",
value: $0.absoluteString
) },
].compactMap { $0 },
body: configuration.encoder.encode(user)
)
Expand Down
2 changes: 1 addition & 1 deletion Sources/PostgREST/PostgrestFilterBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ public class PostgrestFilterBuilder: PostgrestTransformBuilder {
/// - value: The value to filter with
public func `is`(
_ column: String,
value: any URLQueryRepresentable
value: Bool?
) -> PostgrestFilterBuilder {
let queryValue = value.queryValue
mutableState.withValue {
Expand Down
4 changes: 2 additions & 2 deletions Tests/IntegrationTests/Potsgrest/PostgrestFilterTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ final class PostgrestFilterTests: XCTestCase {
}

func testIs() async throws {
let res = try await client.from("users").select("data").is("data", value: AnyJSON.null)
let res = try await client.from("users").select("data").is("data", value: nil)
.execute()
.value as AnyJSON

Expand Down Expand Up @@ -556,7 +556,7 @@ final class PostgrestFilterTests: XCTestCase {
let res = try await client.from("users")
.select()
.eq("username", value: "supabot")
.is("data", value: AnyJSON.null)
.is("data", value: nil)
.overlaps("age_range", value: "[1,2)")
.eq("status", value: "ONLINE")
.textSearch("catchphrase", query: "cat")
Expand Down
2 changes: 1 addition & 1 deletion Tests/PostgRESTTests/BuildURLRequestTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ final class BuildURLRequestTests: XCTestCase {
TestCase(name: "query if nil value") { client in
client.from("users")
.select()
.is("email", value: String?.none)
.is("email", value: nil)
},
TestCase(name: "likeAllOf") { client in
client.from("users")
Expand Down

0 comments on commit 4ba1c7a

Please sign in to comment.