File tree Expand file tree Collapse file tree 2 files changed +18
-7
lines changed Expand file tree Collapse file tree 2 files changed +18
-7
lines changed Original file line number Diff line number Diff line change 2121
2222namespace MacFJA \RediSearch \Query \Builder ;
2323
24- use function call_user_func ;
25- use function is_callable ;
24+ use MacFJA \RediSearch \Query \Escaper ;
2625
2726class Prefix implements QueryElement
2827{
@@ -36,11 +35,7 @@ public function __construct(string $prefix)
3635
3736 public function render (?callable $ escaper = null ): string
3837 {
39- if (is_callable ($ escaper )) {
40- return call_user_func ($ escaper , $ this ->prefix ).'* ' ;
41- }
42-
43- return $ this ->prefix .'* ' ;
38+ return Escaper::escapeWord ($ this ->prefix ).'* ' ;
4439 }
4540
4641 public function priority (): int
Original file line number Diff line number Diff line change @@ -192,6 +192,22 @@ public function testDocGeoExample1(): void
192192 ));
193193 }
194194
195+ /**
196+ * @see https://oss.redis.com/redisearch/Query_Syntax/#prefix_matching
197+ */
198+ public function testDocPrefixExample1 (): void
199+ {
200+ $ expected = 'hel* world ' ;
201+ $ builder = new Builder ();
202+
203+ $ builder
204+ ->addElement (new Builder \Prefix ('hel ' ))
205+ ->addString ('world ' )
206+ ;
207+
208+ static ::assertSame ($ expected , $ builder ->render ());
209+ }
210+
195211 /**
196212 * @see https://oss.redislabs.com/redisearch/Query_Syntax/#fuzzy_matching
197213 */
You can’t perform that action at this time.
0 commit comments