Skip to content

Commit

Permalink
InstanceEnv::delete_by_col_eq: return u32 instead of NonZeroU32 (#539)
Browse files Browse the repository at this point in the history
  • Loading branch information
Centril authored and kulakowski committed Nov 8, 2023
1 parent 5ec7eeb commit 7cd5eef
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
8 changes: 3 additions & 5 deletions crates/core/src/host/instance_env.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use nonempty::NonEmpty;
use parking_lot::{Mutex, MutexGuard};
use spacetimedb_lib::{bsatn, ProductValue};
use std::num::NonZeroU32;
use std::ops::DerefMut;
use std::sync::Arc;

Expand Down Expand Up @@ -159,7 +158,7 @@ impl InstanceEnv {
table_id: TableId,
col_id: ColId,
value: &[u8],
) -> Result<NonZeroU32, NodesError> {
) -> Result<u32, NodesError> {
let stdb = &*self.dbic.relational_db;
let tx = &mut *self.get_tx()?;

Expand All @@ -172,9 +171,8 @@ impl InstanceEnv {
.map(|x| RowId(*x.id()))
.collect::<Vec<_>>();

// Delete them and count how many we deleted and error if none.
let count = stdb.delete(tx, table_id, rows_to_delete);
NonZeroU32::new(count).ok_or(NodesError::ColumnValueNotFound)
// Delete them and count how many we deleted.
Ok(stdb.delete(tx, table_id, rows_to_delete))
}

/// Deletes all rows in the table identified by `table_id`
Expand Down
2 changes: 1 addition & 1 deletion crates/core/src/host/wasmer/wasm_instance_env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ impl WasmInstanceEnv {
.data()
.instance_env
.delete_by_col_eq(&ctx, table_id.into(), col_id.into(), &value)?;
Ok(count.get())
Ok(count)
},
)
}
Expand Down

0 comments on commit 7cd5eef

Please sign in to comment.