Skip to content

fix(postgrest): update parameter of is filter to allow only Bool or nil #382

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

Merged
merged 1 commit into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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