File tree Expand file tree Collapse file tree 2 files changed +34
-1
lines changed
Expand file tree Collapse file tree 2 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -83,7 +83,7 @@ public function prepareSqlRequest(
8383 ): RequestInterface {
8484 $ request = $ this ->initRequest ($ requestSettings );
8585
86- preg_match_all ('~\{([a-zA-Z\d ]+):([a-zA-Z\d ]+(\(.+\))?)}~ ' , $ sql , $ matches );
86+ preg_match_all ('~\{([a-zA-Z\d_ ]+):([a-zA-Z\d ]+(\(.+\))?)}~ ' , $ sql , $ matches );
8787 if ($ matches [0 ] === []) {
8888 $ body = $ this ->streamFactory ->createStream ($ sql );
8989 try {
Original file line number Diff line number Diff line change 44
55namespace SimPod \ClickHouseClient \Tests \Client \Http ;
66
7+ use DateTimeImmutable ;
78use Generator ;
89use Nyholm \Psr7 \Factory \Psr17Factory ;
910use PHPUnit \Framework \Attributes \CoversClass ;
@@ -66,4 +67,36 @@ public static function providerPrepareRequest(): Generator
6667 '?database=database&max_block_size=1 ' ,
6768 ];
6869 }
70+
71+ public function testParamParsed (): void
72+ {
73+ $ requestFactory = new RequestFactory (
74+ new ParamValueConverterRegistry (),
75+ new Psr17Factory (),
76+ new Psr17Factory (),
77+ );
78+
79+ $ request = $ requestFactory ->prepareSqlRequest (
80+ 'SELECT {p1:String}, {p_2:Date} ' ,
81+ new RequestSettings (
82+ [],
83+ [],
84+ ),
85+ new RequestOptions (
86+ [
87+ 'p1 ' => 'value1 ' ,
88+ 'p_2 ' => new DateTimeImmutable (),
89+ ],
90+ ),
91+ );
92+
93+ $ body = $ request ->getBody ()->__toString ();
94+ self ::assertStringContainsString ('param_p1 ' , $ body );
95+ self ::assertStringContainsString (
96+ <<<TEXT
97+ Content-Disposition: form-data; name="param_p_2" \r\nContent-Length: 10 \r\n\r\n2025-01-23
98+ TEXT ,
99+ $ body ,
100+ );
101+ }
69102}
You can’t perform that action at this time.
0 commit comments