Skip to content

Commit 77e1f33

Browse files
authored
sync changes basic-ws (#342)
1 parent 5b6199f commit 77e1f33

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

crates/roc_host/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,7 @@ pub extern "C" fn roc_fx_sqlite_step(
763763
roc_sqlite::step(stmt)
764764
}
765765

766+
/// Resets a prepared statement back to its initial state, ready to be re-executed.
766767
#[no_mangle]
767768
pub extern "C" fn roc_fx_sqlite_reset(stmt: RocBox<()>) -> RocResult<(), roc_sqlite::SqliteError> {
768769
roc_sqlite::reset(stmt)

crates/roc_sqlite/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ pub fn step(stmt: RocBox<()>) -> RocResult<SqliteState, SqliteError> {
292292
roc_err_from_sqlite_errcode(stmt, err)
293293
}
294294

295+
/// Resets a prepared statement back to its initial state, ready to be re-executed.
295296
pub fn reset(stmt: RocBox<()>) -> RocResult<(), SqliteError> {
296297
let stmt: &SqliteStatement = ThreadSafeRefcountedResourceHeap::box_to_resource(stmt);
297298

platform/Sqlite.roc

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -194,12 +194,16 @@ step! = |@Stmt(stmt)|
194194
|> Result.map_err(internal_to_external_error)
195195

196196
# internal use only
197+
## Resets a prepared statement back to its initial state, ready to be re-executed.
197198
reset! : Stmt => Result {} [SqliteErr ErrCode Str]
198199
reset! = |@Stmt(stmt)|
199200
Host.sqlite_reset!(stmt)
200201
|> Result.map_err(internal_to_external_error)
201202

202-
## Execute a SQL statement that doesn't return any rows (like INSERT, UPDATE, DELETE).
203+
## Execute a SQL statement that **doesn't return any rows** (like INSERT, UPDATE, DELETE).
204+
## Use a function starting with `query_` if you expect rows to be returned.
205+
##
206+
## Use execute_prepared! if you expect to run the same query multiple times.
203207
##
204208
## Example:
205209
## ```
@@ -218,12 +222,13 @@ execute! :
218222
query : Str,
219223
bindings : List Binding,
220224
}
221-
=> Result {} [SqliteErr ErrCode Str, UnhandledRows]
225+
=> Result {} [SqliteErr ErrCode Str, RowsReturnedUseQueryInstead]
222226
execute! = |{ path, query: q, bindings }|
223227
stmt = try(prepare!, { path, query: q })
224228
execute_prepared!({ stmt, bindings })
225229

226-
## Execute a prepared SQL statement that doesn't return any rows.
230+
## Execute a prepared SQL statement that **doesn't return any rows** (like INSERT, UPDATE, DELETE).
231+
## Use a function starting with `query_` if you expect rows to be returned.
227232
##
228233
## This is more efficient than [execute!] when running the same query multiple times
229234
## as it reuses the prepared statement.
@@ -232,7 +237,7 @@ execute_prepared! :
232237
stmt : Stmt,
233238
bindings : List Binding,
234239
}
235-
=> Result {} [SqliteErr ErrCode Str, UnhandledRows]
240+
=> Result {} [SqliteErr ErrCode Str, RowsReturnedUseQueryInstead]
236241
execute_prepared! = |{ stmt, bindings }|
237242
try(bind!, stmt, bindings)
238243
res = step!(stmt)
@@ -242,7 +247,7 @@ execute_prepared! = |{ stmt, bindings }|
242247
Ok({})
243248

244249
Ok(Row) ->
245-
Err(UnhandledRows)
250+
Err(RowsReturnedUseQueryInstead)
246251

247252
Err(e) ->
248253
Err(e)

0 commit comments

Comments
 (0)