@@ -5,6 +5,7 @@ const assert = require('assert');
55const mysql = require ( 'mysql' ) ;
66const rds = require ( '../' ) ;
77const config = require ( './config' ) ;
8+ const sleep = require ( 'mz-modules/sleep' ) ;
89
910describe ( 'client.test.js' , function ( ) {
1011 const prefix = 'prefix-' + process . version + '-' ;
@@ -414,6 +415,29 @@ describe('client.test.js', function() {
414415 assert . equal ( ctx . _transactionScopeCount , 3 ) ;
415416 } ) ;
416417 } ) ;
418+
419+ it ( 'should safe with yield Array' , function * ( ) {
420+ const ctx = { } ;
421+ yield [
422+ this . db . beginTransactionScope ( function * ( conn ) {
423+ yield conn . query (
424+ 'INSERT INTO `ali-sdk-test-user` (name, email, mobile) values(?, ?, "12345678901")' ,
425+ [ prefix + 'should-safe-with-yield-array-1' , prefix + 'm@should-safe-with-yield-array-1.com' ]
426+ ) ;
427+ yield sleep ( 100 ) ;
428+ } , ctx ) ,
429+ this . db . beginTransactionScope ( function * ( conn ) {
430+ yield conn . query (
431+ 'INSERT INTO `ali-sdk-test-user` (name, email, mobile) values(?, ?, "12345678901")' ,
432+ [ prefix + 'should-safe-with-yield-array-2' , prefix + 'm@should-safe-with-yield-array-1.com' ]
433+ ) ;
434+ yield sleep ( 200 ) ;
435+ } , ctx ) ,
436+ ] ;
437+ const rows = yield this . db . query (
438+ 'SELECT * FROM `ali-sdk-test-user` where name like "%should-safe-with-yield-array%"' ) ;
439+ assert ( rows . length === 2 ) ;
440+ } ) ;
417441 } ) ;
418442
419443 describe ( 'beginDoomedTransactionScope(scope)' , function ( ) {
0 commit comments