@@ -14,14 +14,15 @@ final class PostgrestTransformsTests: XCTestCase {
1414 configuration: PostgrestClient . Configuration (
1515 url: URL ( string: " \( DotEnv . SUPABASE_URL) /rest/v1 " ) !,
1616 headers: [
17- " apikey " : DotEnv . SUPABASE_ANON_KEY,
17+ " apikey " : DotEnv . SUPABASE_ANON_KEY
1818 ] ,
1919 logger: nil
2020 )
2121 )
2222
2323 func testOrder( ) async throws {
24- let res = try await client. from ( " users " )
24+ let res =
25+ try await client. from ( " users " )
2526 . select ( )
2627 . order ( " username " , ascending: false )
2728 . execute ( ) . value as AnyJSON
@@ -63,7 +64,8 @@ final class PostgrestTransformsTests: XCTestCase {
6364 }
6465
6566 func testOrderOnMultipleColumns( ) async throws {
66- let res = try await client. from ( " messages " )
67+ let res =
68+ try await client. from ( " messages " )
6769 . select ( )
6870 . order ( " channel_id " , ascending: false )
6971 . order ( " username " , ascending: false )
@@ -92,7 +94,8 @@ final class PostgrestTransformsTests: XCTestCase {
9294 }
9395
9496 func testLimit( ) async throws {
95- let res = try await client. from ( " users " )
97+ let res =
98+ try await client. from ( " users " )
9699 . select ( )
97100 . limit ( 1 )
98101 . execute ( ) . value as AnyJSON
@@ -113,7 +116,8 @@ final class PostgrestTransformsTests: XCTestCase {
113116 }
114117
115118 func testRange( ) async throws {
116- let res = try await client. from ( " users " )
119+ let res =
120+ try await client. from ( " users " )
117121 . select ( )
118122 . range ( from: 1 , to: 3 )
119123 . execute ( ) . value as AnyJSON
@@ -148,7 +152,8 @@ final class PostgrestTransformsTests: XCTestCase {
148152 }
149153
150154 func testSingle( ) async throws {
151- let res = try await client. from ( " users " )
155+ let res =
156+ try await client. from ( " users " )
152157 . select ( )
153158 . limit ( 1 )
154159 . single ( )
@@ -168,7 +173,8 @@ final class PostgrestTransformsTests: XCTestCase {
168173 }
169174
170175 func testSingleOnInsert( ) async throws {
171- let res = try await client. from ( " users " )
176+ let res =
177+ try await client. from ( " users " )
172178 . insert ( [ " username " : " foo " ] )
173179 . select ( )
174180 . single ( )
@@ -193,7 +199,8 @@ final class PostgrestTransformsTests: XCTestCase {
193199 }
194200
195201 func testSelectOnInsert( ) async throws {
196- let res = try await client. from ( " users " )
202+ let res =
203+ try await client. from ( " users " )
197204 . insert ( [ " username " : " foo " ] )
198205 . select ( " status " )
199206 . execute ( ) . value as AnyJSON
@@ -215,7 +222,8 @@ final class PostgrestTransformsTests: XCTestCase {
215222 }
216223
217224 func testSelectOnRpc( ) async throws {
218- let res = try await client. rpc ( " get_username_and_status " , params: [ " name_param " : " supabot " ] )
225+ let res =
226+ try await client. rpc ( " get_username_and_status " , params: [ " name_param " : " supabot " ] )
219227 . select ( " status " )
220228 . execute ( ) . value as AnyJSON
221229
@@ -230,6 +238,29 @@ final class PostgrestTransformsTests: XCTestCase {
230238 }
231239 }
232240
241+ func testRpcWithArray( ) async throws {
242+ struct Params : Encodable {
243+ let arr : [ Int ]
244+ let index : Int
245+ }
246+ let res =
247+ try await client. rpc ( " get_array_element " , params: Params ( arr: [ 37 , 420 , 64 ] , index: 2 ) )
248+ . execute ( ) . value as Int
249+ XCTAssertEqual ( res, 420 )
250+ }
251+
252+ func testRpcWithReadOnlyAccessMode( ) async throws {
253+ struct Params : Encodable {
254+ let arr : [ Int ]
255+ let index : Int
256+ }
257+ let res =
258+ try await client. rpc (
259+ " get_array_element " , params: Params ( arr: [ 37 , 420 , 64 ] , index: 2 ) , get: true
260+ ) . execute ( ) . value as Int
261+ XCTAssertEqual ( res, 420 )
262+ }
263+
233264 func testCsv( ) async throws {
234265 let res = try await client. from ( " users " ) . select ( ) . csv ( ) . execute ( ) . string ( )
235266 assertInlineSnapshot ( of: res, as: . json) {
0 commit comments