Skip to content

Commit 18141fa

Browse files
committed
cached query results are not optional
json null values are not allowed, instead they prefer to not have the items at all, in case ids did not exist
1 parent bbc2dd4 commit 18141fa

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

frameworks/Rust/rama/src/main_sqlx.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,12 @@ async fn cache(
110110
) -> impl IntoResponse {
111111
let count = parse_params(params);
112112
let mut rng = SmallRng::from_rng(&mut rng());
113-
let mut worlds: Vec<Option<World>> = Vec::with_capacity(count);
113+
let mut worlds: Vec<World> = Vec::with_capacity(count);
114114

115115
for id in random_ids(&mut rng, count) {
116-
worlds.push(ctx.state().cache.get(&id));
116+
if let Some(world) = ctx.state().cache.get(&id) {
117+
worlds.push(world);
118+
}
117119
}
118120

119121
(StatusCode::OK, Json(worlds))

0 commit comments

Comments
 (0)