11#[ macro_use]
2- extern crate redismodule ;
2+ extern crate redis_module ;
33
4- use redismodule :: native_types:: RedisType ;
5- use redismodule :: raw:: RedisModuleTypeMethods ;
6- use redismodule :: { raw as rawmod, NextArg } ;
7- use redismodule :: { Context , RedisError , RedisResult , RedisValue , REDIS_OK } ;
4+ use redis_module :: native_types:: RedisType ;
5+ use redis_module :: raw:: RedisModuleTypeMethods ;
6+ use redis_module :: { raw as rawmod, NextArg } ;
7+ use redis_module :: { Context , RedisError , RedisResult , RedisValue , REDIS_OK } ;
88use serde_json:: { Number , Value } ;
99
1010use std:: { i64, usize} ;
@@ -20,13 +20,13 @@ mod schema; // TODO: Remove
2020use crate :: array_index:: ArrayIndex ;
2121use crate :: commands:: index;
2222use crate :: error:: Error ;
23- use crate :: redisjson:: { Format , RedisJSON , SetOptions } ;
23+ use crate :: redisjson:: { Format , Path , RedisJSON , SetOptions } ;
2424
2525static REDIS_JSON_TYPE : RedisType = RedisType :: new (
2626 "ReJSON-RL" ,
2727 2 ,
2828 RedisModuleTypeMethods {
29- version : redismodule :: TYPE_METHOD_VERSION ,
29+ version : redis_module :: TYPE_METHOD_VERSION ,
3030
3131 rdb_load : Some ( redisjson:: type_methods:: rdb_load) ,
3232 rdb_save : Some ( redisjson:: type_methods:: rdb_save) ,
@@ -165,7 +165,7 @@ fn json_get(ctx: &Context, args: Vec<String>) -> RedisResult {
165165 let mut args = args. into_iter ( ) . skip ( 1 ) ;
166166 let key = args. next_string ( ) ?;
167167
168- let mut paths: Vec < String > = vec ! [ ] ;
168+ let mut paths: Vec < Path > = vec ! [ ] ;
169169 let mut first_loop = true ;
170170 let mut format = Format :: JSON ;
171171 loop {
@@ -174,7 +174,7 @@ fn json_get(ctx: &Context, args: Vec<String>) -> RedisResult {
174174 Err ( _) => {
175175 // path is optional -> no path found on the first loop we use root "$"
176176 if first_loop {
177- paths. push ( "$" . to_owned ( ) ) ;
177+ paths. push ( Path :: new ( "$" . to_string ( ) ) ) ;
178178 }
179179 break ;
180180 }
@@ -198,15 +198,15 @@ fn json_get(ctx: &Context, args: Vec<String>) -> RedisResult {
198198 format = Format :: from_str ( args. next_string ( ) ?. as_str ( ) ) ?;
199199 }
200200 _ => {
201- paths. push ( backwards_compat_path ( arg) ) ;
201+ paths. push ( Path :: new ( arg) ) ;
202202 }
203203 } ;
204204 }
205205
206206 let key = ctx. open_key_writable ( & key) ;
207207 let value = match key. get_value :: < RedisJSON > ( & REDIS_JSON_TYPE ) ? {
208208 Some ( doc) => if paths. len ( ) == 1 {
209- doc. to_string ( & paths[ 0 ] , format) ?
209+ doc. to_string ( & paths[ 0 ] . fixed , format) ?
210210 } else {
211211 // can't be smaller than 1
212212 doc. to_json ( & mut paths) ?
0 commit comments