-
Couldn't load subscription status.
- Fork 17
Description
Bug report
Describe the bug
We are running a query with a gt query on a timestamptz field. We are passing a timestamptz string, which we received from supabase into the query to fetch newer rows, however since the string contains a +, the query will not be escaped correctly, as + is an allowed character. In order for the query to work, + needs to be escaped with %2B, otherwise supabase will return an error.
If we escape the + before passing it to postgrest-swift, the escaped string gets escaped again, also resulting in an error.
To Reproduce
Run the following code on a table with a received_at field, which has the type timestamptz.
let response = try await client.database.from("tasks")
.select()
.gt(column: "received_at", value: "2023-03-23T15:50:30.511743+00:00")
.order(column: "received_at")
.execute()This will return the following error from the server:
{
"code": "22007",
"details": null,
"hint": null,
"message": "invalid input syntax for type timestamp with time zone: \"2023-03-23T15:50:31.511743 00:00\""
}Expected behavior
I'm not what the best approach would be. The easiest for this case would be to escape the + internally, but I could expect this to be a breaking change and lead to other issues.
As the APIClient on PostgrestClient and the APIClient.delegate are non-public, it is currently not possible to adjust the escaping behavior from outside the library. Have you considered making the library more configurable here?
If they would be exposed, I could implement the func client<T>(_ client: APIClient, makeURLForRequest request: Request<T>) throws -> URL? on APIClientDelegate to escape the string correctly.
System information
- OS: macOS
- Version of supabase-swift: 0.2.1