Skip to content

Commit f9f1310

Browse files
No overloading support at the moment
1 parent edc809a commit f9f1310

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

rholang/src/rust/interpreter/chromadb_service.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,10 @@ impl ChromaDBService {
106106
/// # Arguments
107107
///
108108
/// * `name` - The name of the collection to create
109-
/// * `ignore_or_update_if_exists` - If true, update collection metadata (if provided, else ignore)
110-
/// if it already exists. Otherwise, error if exists.
109+
/// * `ignore_or_update_if_exists` -
110+
/// If true and a non-empty collection metadata is proivded, update any existing metadata.
111+
/// If true and no metadata is provided, ignore existing collection.
112+
/// If false, error if a collection with the same name already exists.
111113
/// * `metadata` - Optional metadata to associate with the collection.
112114
/// Must be a JSON object with keys and values that are either numbers, strings or floats.
113115
pub async fn create_collection(
@@ -117,7 +119,7 @@ impl ChromaDBService {
117119
smart_metadata: Option<CollectionMetadata>,
118120
) -> Result<(), InterpreterError> {
119121
let metadata: Option<serde_json::Map<String, serde_json::Value>> =
120-
smart_metadata.map(|x| x.into());
122+
smart_metadata.and_then(|x| if x.0.is_empty() { None } else { Some(x.into()) });
121123
let metadata_ref = metadata.as_ref();
122124
self.client
123125
.create_collection(name, metadata.clone(), ignore_or_update_if_exists)

rholang/src/rust/interpreter/system_processes.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1335,15 +1335,16 @@ impl SystemProcesses {
13351335
};
13361336
Ok((collection_name, update_if_exists, Some(metadata), ack))
13371337
}
1338-
[collection_name_par, ignore_if_exists_par, ack] => {
1339-
let (Some(collection_name), Some(ignore_if_exists)) = (
1340-
RhoString::unapply(collection_name_par),
1341-
RhoBoolean::unapply(ignore_if_exists_par),
1342-
) else {
1343-
return Err(illegal_argument_error("chroma_create_collection"));
1344-
};
1345-
Ok((collection_name, ignore_if_exists, None, ack))
1346-
}
1338+
// TODO (chase): If overloading is supported for system processes - support the below method as well.
1339+
// [collection_name_par, ignore_if_exists_par, ack] => {
1340+
// let (Some(collection_name), Some(ignore_if_exists)) = (
1341+
// RhoString::unapply(collection_name_par),
1342+
// RhoBoolean::unapply(ignore_if_exists_par),
1343+
// ) else {
1344+
// return Err(illegal_argument_error("chroma_create_collection"));
1345+
// };
1346+
// Ok((collection_name, ignore_if_exists, None, ack))
1347+
// }
13471348
_ => Err(illegal_argument_error("chroma_create_collection")),
13481349
}?;
13491350

0 commit comments

Comments
 (0)