File tree Expand file tree Collapse file tree 3 files changed +43
-2
lines changed
Expand file tree Collapse file tree 3 files changed +43
-2
lines changed Original file line number Diff line number Diff line change 1717 "text": "infection-log.txt"
1818 },
1919 "minMsi": 90,
20- "minCoveredMsi": 96
20+ "minCoveredMsi": 95
2121}
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 ;
1415use SimPod \ClickHouseClient \Param \ParamValueConverterRegistry ;
1516use SimPod \ClickHouseClient \Tests \TestCaseBase ;
1617
18+ use function implode ;
19+
1720#[CoversClass(RequestFactory::class)]
1821final class RequestFactoryTest extends TestCaseBase
1922{
@@ -66,4 +69,42 @@ public static function providerPrepareRequest(): Generator
6669 '?database=database&max_block_size=1 ' ,
6770 ];
6871 }
72+
73+ public function testParamParsed (): void
74+ {
75+ $ requestFactory = new RequestFactory (
76+ new ParamValueConverterRegistry (),
77+ new Psr17Factory (),
78+ new Psr17Factory (),
79+ );
80+
81+ $ request = $ requestFactory ->prepareSqlRequest (
82+ 'SELECT {p1:String}, {p_2:Date} ' ,
83+ new RequestSettings (
84+ [],
85+ [],
86+ ),
87+ new RequestOptions (
88+ [
89+ 'p1 ' => 'value1 ' ,
90+ 'p_2 ' => new DateTimeImmutable (),
91+ ],
92+ ),
93+ );
94+
95+ $ body = $ request ->getBody ()->__toString ();
96+ self ::assertStringContainsString ('param_p1 ' , $ body );
97+ self ::assertStringContainsString (
98+ implode (
99+ "\r\n" ,
100+ [
101+ 'Content-Disposition: form-data; name="param_p_2" ' ,
102+ 'Content-Length: 10 ' ,
103+ '' ,
104+ '2025-01-23 ' ,
105+ ],
106+ ),
107+ $ body ,
108+ );
109+ }
69110}
You can’t perform that action at this time.
0 commit comments