File tree Expand file tree Collapse file tree 2 files changed +24
-4
lines changed
lib/Doctrine/DBAL/Connections
tests/Doctrine/Tests/DBAL/Functional Expand file tree Collapse file tree 2 files changed +24
-4
lines changed Original file line number Diff line number Diff line change @@ -163,11 +163,12 @@ public function connect($connectionName = null)
163
163
}
164
164
165
165
if ($ this ->connections [$ connectionName ]) {
166
- if ( $ forceMasterAsSlave ) {
167
- $ this -> connections [ ' slave ' ] = $ this -> _conn = $ this -> connections [ ' master ' ];
168
- } else {
169
- $ this ->_conn = $ this ->connections [ $ connectionName ] ;
166
+ $ this -> _conn = $ this -> connections [ $ connectionName ];
167
+
168
+ if ( $ forceMasterAsSlave && ! $ this -> keepSlave ) {
169
+ $ this ->connections [ ' slave ' ] = $ this ->_conn ;
170
170
}
171
+
171
172
return false ;
172
173
}
173
174
Original file line number Diff line number Diff line change @@ -102,4 +102,23 @@ public function testKeepSlaveBeginTransactionStaysOnMaster()
102
102
$ conn ->connect ('slave ' );
103
103
$ this ->assertFalse ($ conn ->isConnectedToMaster ());
104
104
}
105
+
106
+ /**
107
+ * @group DBAL-335
108
+ */
109
+ public function testKeepSlaveInsertStaysOnMaster ()
110
+ {
111
+ $ conn = $ this ->createMasterSlaveConnection ($ keepSlave = true );
112
+ $ conn ->connect ('slave ' );
113
+
114
+ $ conn ->insert ('master_slave_table ' , array ('test_int ' => 30 ));
115
+
116
+ $ this ->assertTrue ($ conn ->isConnectedToMaster ());
117
+
118
+ $ conn ->connect ();
119
+ $ this ->assertTrue ($ conn ->isConnectedToMaster ());
120
+
121
+ $ conn ->connect ('slave ' );
122
+ $ this ->assertFalse ($ conn ->isConnectedToMaster ());
123
+ }
105
124
}
You can’t perform that action at this time.
0 commit comments