Skip to content

Commit c3d3e45

Browse files
Rename from and fix rpc builder (#8)
* Fixed RPC builder, removed testing framework Fixed a bug with the RPC builder setting the query builder's method to the RPC's schema. Added a test for RPC functions. Removed unnecessary testing framework. Updated README.md * Add Test for RPC function call * Fix RPC builder bug RPC builder was passing `schema` to the `method` property. * Rename `form` to `from` * Update PostgrestBuilder.swift
1 parent ecabbbc commit c3d3e45

File tree

4 files changed

+14
-4
lines changed

4 files changed

+14
-4
lines changed

Package.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ let package = Package(
1414
.executable(name: "example", targets: ["example"]),
1515
],
1616
dependencies: [
17-
// Dependencies declare other packages that this package depends on.
1817
.package(
1918
name: "SnapshotTesting",
2019
url: "https://github.com/pointfreeco/swift-snapshot-testing.git", from: "1.8.1"

Sources/PostgREST/PostgrestRpcBuilder.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@ public class PostgrestRpcBuilder: PostgrestBuilder {
33
method = "POST"
44
body = parameters
55
return PostgrestTransformBuilder(
6-
url: url, queryParams: queryParams, headers: headers, schema: schema, method: schema,
7-
body: body
8-
)
6+
url: url,
7+
queryParams: queryParams,
8+
headers: headers,
9+
schema: schema,
10+
method: method,
11+
body: body)
912
}
1013
}

Tests/PostgRESTTests/BuildURLRequestTests.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ final class BuildURLRequestTests: XCTestCase {
2828
.insert(values: ["email": "[email protected]"])
2929
.buildURLRequest(head: false, count: nil)
3030
},
31+
TestCase(name: "call rpc") { client in
32+
try client.rpc(fn: "test_fcn", parameters: ["KEY": "VALUE"])
33+
.buildURLRequest(head: false, count: nil)
34+
}
3135
]
3236

3337
for testCase in testCases {
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
curl \
2+
--request POST \
3+
--data "{\"KEY\":\"VALUE\"}" \
4+
"https://example.supabase.co/rpc/test_fcn"

0 commit comments

Comments
 (0)