@@ -300,7 +300,9 @@ public function provideSqlDataWillBeReturnedWithType()
300300 ['2.5 ' , 2.5 ],
301301 ['null ' , null ],
302302 ['"hello" ' , 'hello ' ],
303- ['"hellö" ' , 'hellö ' ]
303+ ['"hellö" ' , 'hellö ' ],
304+ ['X \'01020300 \'' , "\x01\x02\x03\x00" ],
305+ ['X \'3FF3 \'' , "\x3f\xf3" ]
304306 ],
305307 (PHP_VERSION_ID < 50606 ) ? [] : [
306308 // preserving zero fractions is only supported as of PHP 5.6.6
@@ -345,16 +347,21 @@ public function provideDataWillBeReturnedWithType()
345347 {
346348 return array_merge (
347349 [
348- [0 ],
349- [1 ],
350- [1.5 ],
351- [null ],
352- ['hello ' ],
353- ['hellö ' ]
350+ [0 , 'INTEGER ' ],
351+ [1 , 'INTEGER ' ],
352+ [1.5 , 'REAL ' ],
353+ [null , 'NULL ' ],
354+ ['hello ' , 'TEXT ' ],
355+ ['hellö ' , 'TEXT ' ],
356+ ["hello \tworld \r\n" , 'TEXT ' ],
357+ [utf8_decode ('hello wörld! ' ), 'BLOB ' ],
358+ ["hello \x7fö " , 'BLOB ' ],
359+ ["\x03\x02\x001 " , 'BLOB ' ],
360+ ["a \000b " , 'BLOB ' ]
354361 ],
355362 (PHP_VERSION_ID < 50606 ) ? [] : [
356363 // preserving zero fractions is only supported as of PHP 5.6.6
357- [1.0 ]
364+ [1.0 , ' REAL ' ]
358365 ]
359366 );
360367 }
@@ -363,7 +370,7 @@ public function provideDataWillBeReturnedWithType()
363370 * @dataProvider provideDataWillBeReturnedWithType
364371 * @param mixed $value
365372 */
366- public function testQueryValuePlaceholderPositionalResolvesWithResultWithExactTypeAndRunsUntilQuit ($ value )
373+ public function testQueryValuePlaceholderPositionalResolvesWithResultWithExactTypeAndRunsUntilQuit ($ value, $ type )
367374 {
368375 $ loop = React \EventLoop \Factory::create ();
369376 $ factory = new Factory ($ loop );
@@ -372,7 +379,7 @@ public function testQueryValuePlaceholderPositionalResolvesWithResultWithExactTy
372379
373380 $ data = null ;
374381 $ promise ->then (function (DatabaseInterface $ db ) use (&$ data , $ value ){
375- $ db ->query ('SELECT ? AS value ' , array ($ value ))->then (function (Result $ result ) use (&$ data ) {
382+ $ db ->query ('SELECT ? AS value, UPPER(TYPEOF(?)) as type ' , array ($ value , $ value ))->then (function (Result $ result ) use (&$ data ) {
376383 $ data = $ result ->rows ;
377384 });
378385
@@ -381,14 +388,14 @@ public function testQueryValuePlaceholderPositionalResolvesWithResultWithExactTy
381388
382389 $ loop ->run ();
383390
384- $ this ->assertSame (array (array ('value ' => $ value )), $ data );
391+ $ this ->assertSame (array (array ('value ' => $ value, ' type ' => $ type )), $ data );
385392 }
386393
387394 /**
388395 * @dataProvider provideDataWillBeReturnedWithType
389396 * @param mixed $value
390397 */
391- public function testQueryValuePlaceholderNamedResolvesWithResultWithExactTypeAndRunsUntilQuit ($ value )
398+ public function testQueryValuePlaceholderNamedResolvesWithResultWithExactTypeAndRunsUntilQuit ($ value, $ type )
392399 {
393400 $ loop = React \EventLoop \Factory::create ();
394401 $ factory = new Factory ($ loop );
@@ -397,7 +404,7 @@ public function testQueryValuePlaceholderNamedResolvesWithResultWithExactTypeAnd
397404
398405 $ data = null ;
399406 $ promise ->then (function (DatabaseInterface $ db ) use (&$ data , $ value ){
400- $ db ->query ('SELECT :value AS value ' , array ('value ' => $ value ))->then (function (Result $ result ) use (&$ data ) {
407+ $ db ->query ('SELECT :value AS value, UPPER(TYPEOF(:value)) AS type ' , array ('value ' => $ value ))->then (function (Result $ result ) use (&$ data ) {
401408 $ data = $ result ->rows ;
402409 });
403410
@@ -406,7 +413,7 @@ public function testQueryValuePlaceholderNamedResolvesWithResultWithExactTypeAnd
406413
407414 $ loop ->run ();
408415
409- $ this ->assertSame (array (array ('value ' => $ value )), $ data );
416+ $ this ->assertSame (array (array ('value ' => $ value, ' type ' => $ type )), $ data );
410417 }
411418
412419 public function provideDataWillBeReturnedWithOtherType ()
0 commit comments