Skip to content

Commit

Permalink
value: fix cass_value_is_collection
Browse files Browse the repository at this point in the history
previously, we would not consider null collections
  • Loading branch information
muzarski committed Jul 31, 2024
1 parent 1161819 commit e89b178
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions scylla-rust-wrapper/src/query_result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1165,12 +1165,12 @@ pub unsafe extern "C" fn cass_value_is_null(value: *const CassValue) -> cass_boo
pub unsafe extern "C" fn cass_value_is_collection(value: *const CassValue) -> cass_bool_t {
let val = ptr_to_ref(value);

match val.value {
Some(Value::CollectionValue(Collection::List(_))) => true as cass_bool_t,
Some(Value::CollectionValue(Collection::Set(_))) => true as cass_bool_t,
Some(Value::CollectionValue(Collection::Map(_))) => true as cass_bool_t,
_ => false as cass_bool_t,
}
matches!(
val.value_type.get_value_type(),
CassValueType::CASS_VALUE_TYPE_LIST
| CassValueType::CASS_VALUE_TYPE_SET
| CassValueType::CASS_VALUE_TYPE_MAP
) as cass_bool_t
}

#[no_mangle]
Expand Down Expand Up @@ -1545,9 +1545,6 @@ extern "C" {
extern "C" {
pub fn cass_value_type(value: *const CassValue) -> CassValueType;
}
extern "C" {
pub fn cass_value_is_collection(value: *const CassValue) -> cass_bool_t;
}
extern "C" {
pub fn cass_value_item_count(collection: *const CassValue) -> size_t;
}
Expand Down

0 comments on commit e89b178

Please sign in to comment.