@@ -478,34 +478,59 @@ public function test_stale_reads(): void
478478 $ this ->assertNotEmpty ($ timestamp );
479479
480480 $ timestampBound = new StrongRead ();
481- $ rows = $ conn ->selectWithOptions ("SELECT * FROM $ { tableName} WHERE userID = ? " , [$ uuid ], $ timestampBound ->transactionOptions ());
481+ $ rows = $ conn ->selectWithOptions ("SELECT * FROM { $ tableName } WHERE userId = ? " , [$ uuid ], $ timestampBound ->transactionOptions ());
482482 $ this ->assertCount (1 , $ rows );
483483 $ this ->assertSame ($ uuid , $ rows [0 ]['userId ' ]);
484484 $ this ->assertSame ('first ' , $ rows [0 ]['name ' ]);
485485
486486 $ oldDatetime = Carbon::instance ($ timestamp ->get ())->subSecond ();
487487
488488 $ timestampBound = new ReadTimestamp ($ oldDatetime );
489- $ rows = $ conn ->selectWithOptions ("SELECT * FROM $ { tableName} WHERE userID = ? " , [$ uuid ], $ timestampBound ->transactionOptions ());
489+ $ rows = $ conn ->selectWithOptions ("SELECT * FROM { $ tableName } WHERE userId = ? " , [$ uuid ], $ timestampBound ->transactionOptions ());
490490 $ this ->assertEmpty ($ rows );
491491
492492 $ timestampBound = new ExactStaleness (10 );
493- $ rows = $ conn ->selectWithOptions ("SELECT * FROM $ { tableName} WHERE userID = ? " , [$ uuid ], $ timestampBound ->transactionOptions ());
493+ $ rows = $ conn ->selectWithOptions ("SELECT * FROM { $ tableName } WHERE userId = ? " , [$ uuid ], $ timestampBound ->transactionOptions ());
494494 $ this ->assertEmpty ($ rows );
495495
496496 $ timestampBound = new MaxStaleness (10 );
497- $ rows = $ conn ->selectWithOptions ("SELECT * FROM $ { tableName} WHERE userID = ? " , [$ uuid ], $ timestampBound ->transactionOptions ());
497+ $ rows = $ conn ->selectWithOptions ("SELECT * FROM { $ tableName } WHERE userId = ? " , [$ uuid ], $ timestampBound ->transactionOptions ());
498498 $ this ->assertCount (1 , $ rows );
499499 $ this ->assertSame ($ uuid , $ rows [0 ]['userId ' ]);
500500 $ this ->assertSame ('first ' , $ rows [0 ]['name ' ]);
501501
502502 $ timestampBound = new MinReadTimestamp ($ oldDatetime );
503- $ rows = $ conn ->selectWithOptions ("SELECT * FROM $ { tableName} WHERE userID = ? " , [$ uuid ], $ timestampBound ->transactionOptions ());
503+ $ rows = $ conn ->selectWithOptions ("SELECT * FROM { $ tableName } WHERE userId = ? " , [$ uuid ], $ timestampBound ->transactionOptions ());
504504 $ this ->assertCount (1 , $ rows );
505505 $ this ->assertSame ($ uuid , $ rows [0 ]['userId ' ]);
506506 $ this ->assertSame ('first ' , $ rows [0 ]['name ' ]);
507507 }
508508
509+ public function test_stale_reads_in_transaction (): void
510+ {
511+ $ conn = $ this ->getDefaultConnection ();
512+ $ tableName = self ::TABLE_NAME_USER ;
513+ $ uuid = $ this ->generateUuid ();
514+
515+ $ conn ->transaction (function (Connection $ conn ) use ($ tableName , $ uuid ) {
516+ $ conn ->insert ("INSERT INTO {$ tableName } (`userId`, `name`) VALUES (' {$ uuid }', 'first') " );
517+
518+ $ oldDatetime = now ()->subSecond ();
519+
520+ $ bounds = [
521+ new StrongRead (),
522+ new ExactStaleness (10 ),
523+ new MaxStaleness (10 ),
524+ new ReadTimestamp ($ oldDatetime ),
525+ new MinReadTimestamp ($ oldDatetime ),
526+ ];
527+ foreach ($ bounds as $ timestampBound ) {
528+ $ rows = $ conn ->selectWithOptions ("SELECT * FROM {$ tableName } WHERE userId = ? " , [$ uuid ], $ timestampBound ->transactionOptions ());
529+ $ this ->assertEmpty ($ rows );
530+ }
531+ });
532+ }
533+
509534 public function testEventListenOrder (): void
510535 {
511536 $ receivedEventClasses = [];
0 commit comments