-
-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add columns query param to insert and upsert methods
- Loading branch information
Showing
6 changed files
with
52 additions
and
94 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,11 @@ import XCTest | |
import FoundationNetworking | ||
#endif | ||
|
||
struct User: Encodable { | ||
var email: String | ||
var username: String? | ||
} | ||
|
||
@MainActor | ||
final class BuildURLRequestTests: XCTestCase { | ||
let url = URL(string: "https://example.supabase.co")! | ||
|
@@ -55,7 +60,16 @@ final class BuildURLRequestTests: XCTestCase { | |
}, | ||
TestCase(name: "insert new user") { client in | ||
try await client.from("users") | ||
.insert(["email": "[email protected]"]) | ||
.insert(User(email: "[email protected]")) | ||
}, | ||
TestCase(name: "bulk insert users") { client in | ||
try await client.from("users") | ||
.insert( | ||
[ | ||
User(email: "[email protected]"), | ||
User(email: "[email protected]", username: "johndoe2"), | ||
] | ||
) | ||
}, | ||
TestCase(name: "call rpc") { client in | ||
try await client.rpc("test_fcn", params: ["KEY": "VALUE"]) | ||
|
@@ -89,11 +103,20 @@ final class BuildURLRequestTests: XCTestCase { | |
}, | ||
TestCase(name: "test upsert not ignoring duplicates") { client in | ||
try await client.from("users") | ||
.upsert(["email": "[email protected]"]) | ||
.upsert(User(email: "[email protected]")) | ||
}, | ||
TestCase(name: "bulk upsert") { client in | ||
try await client.from("users") | ||
.upsert( | ||
[ | ||
User(email: "[email protected]"), | ||
User(email: "[email protected]", username: "johndoe2"), | ||
] | ||
) | ||
}, | ||
TestCase(name: "test upsert ignoring duplicates") { client in | ||
try await client.from("users") | ||
.upsert(["email": "[email protected]"], ignoreDuplicates: true) | ||
.upsert(User(email: "[email protected]"), ignoreDuplicates: true) | ||
}, | ||
TestCase(name: "query with + character") { client in | ||
await client.from("users") | ||
|
This file was deleted.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions
7
.../PostgRESTTests/__Snapshots__/BuildURLRequestTests/testBuildRequest.bulk-insert-users.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
curl \ | ||
--request POST \ | ||
--header "Accept: application/json" \ | ||
--header "Content-Type: application/json" \ | ||
--header "X-Client-Info: postgrest-swift/x.y.z" \ | ||
--data "[{\"email\":\"[email protected]\"},{\"email\":\"[email protected]\",\"username\":\"johndoe2\"}]" \ | ||
"https://example.supabase.co/users?columns=email,username" |
8 changes: 8 additions & 0 deletions
8
Tests/PostgRESTTests/__Snapshots__/BuildURLRequestTests/testBuildRequest.bulk-upsert.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
curl \ | ||
--request POST \ | ||
--header "Accept: application/json" \ | ||
--header "Content-Type: application/json" \ | ||
--header "Prefer: resolution=merge-duplicates,return=representation" \ | ||
--header "X-Client-Info: postgrest-swift/x.y.z" \ | ||
--data "[{\"email\":\"[email protected]\"},{\"email\":\"[email protected]\",\"username\":\"johndoe2\"}]" \ | ||
"https://example.supabase.co/users?columns=email,username" |