Skip to content

Commit d34cdd3

Browse files
committed
Fix k/v type arg generation in ddl::Keymap
A test for the same was added Signed-off-by: Sayan Nandan <[email protected]>
1 parent 31f8c50 commit d34cdd3

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/ddl.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ impl CreateTableIntoQuery for Keymap {
126126
.unwrap_or(&KeymapType::Binstr)
127127
.priv_to_string(),
128128
vtype = self
129-
.ktype
129+
.vtype
130130
.as_ref()
131131
.unwrap_or(&KeymapType::Binstr)
132132
.priv_to_string(),
@@ -256,3 +256,17 @@ implement_ddl! {
256256
Element::RespCode(RespCode::Okay) => {}
257257
}
258258
}
259+
260+
#[cfg(test)]
261+
mod tests {
262+
use super::{CreateTableIntoQuery, Keymap, KeymapType};
263+
#[test]
264+
fn test_query_generation_from_keymap() {
265+
let qgen = Keymap::new("mytbl")
266+
.set_ktype(KeymapType::Str)
267+
.set_vtype(KeymapType::Binstr)
268+
.into_query();
269+
let qman = crate::query!("CREATE", "TABLE", "mytbl", "keymap(str,binstr)");
270+
assert_eq!(qgen, qman);
271+
}
272+
}

0 commit comments

Comments
 (0)