@@ -18,6 +18,7 @@ import io.github.jan.supabase.postgrest.request.UpdateRequest
1818import io.github.jan.supabase.postgrest.result.PostgrestResult
1919import io.ktor.client.plugins.HttpRequestTimeoutException
2020import kotlinx.serialization.json.JsonArray
21+ import kotlinx.serialization.json.JsonElement
2122import kotlinx.serialization.json.jsonArray
2223import kotlinx.serialization.json.jsonObject
2324
@@ -230,28 +231,47 @@ class PostgrestQueryBuilder(
230231 *
231232 * By default, updated rows are not returned. To return it, call `[PostgrestRequestBuilder.select]`.
232233 *
233- * @param value The value to update, will automatically get serialized into json .
234+ * @param body The request body representing the value to update .
234235 * @param request Additional filtering to apply to the query
235236 * @throws PostgrestRestException if receiving an error response
236237 * @throws HttpRequestTimeoutException if the request timed out
237238 * @throws HttpRequestException on network related issues
238239 */
239- suspend inline fun < reified T : Any > update (
240- value : T ,
240+ suspend inline fun update (
241+ body : JsonElement ,
241242 request : PostgrestRequestBuilder .() -> Unit = {}
242243 ): PostgrestResult {
243244 val requestBuilder = PostgrestRequestBuilder (postgrest.config.propertyConversionMethod).apply (request)
244245 val updateRequest = UpdateRequest (
246+ body = body,
245247 returning = requestBuilder.returning,
246248 count = requestBuilder.count,
247249 urlParams = requestBuilder.params.mapToFirstValue(),
248- body = postgrest.serializer.encodeToJsonElement(value),
249250 schema = schema,
250251 headers = requestBuilder.headers.build()
251252 )
252253 return RestRequestExecutor .execute(postgrest = postgrest, path = table, request = updateRequest)
253254 }
254255
256+ /* *
257+ * Executes an update operation on the [table].
258+ *
259+ * By default, updated rows are not returned. To return it, call `[PostgrestRequestBuilder.select]`.
260+ *
261+ * @param value The value to update, will automatically get serialized into json.
262+ * @param request Additional filtering to apply to the query
263+ * @throws PostgrestRestException if receiving an error response
264+ * @throws HttpRequestTimeoutException if the request timed out
265+ * @throws HttpRequestException on network related issues
266+ */
267+ suspend inline fun <reified T : Any > update (
268+ value : T ,
269+ request : PostgrestRequestBuilder .() -> Unit = {}
270+ ): PostgrestResult = update(
271+ body = postgrest.serializer.encodeToJsonElement(value),
272+ request = request
273+ )
274+
255275 /* *
256276 * Executes a delete operation on the [table].
257277 *
0 commit comments