File tree Expand file tree Collapse file tree 3 files changed +31
-1
lines changed
src/MySqlConnector/MySqlClient Expand file tree Collapse file tree 3 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -157,7 +157,7 @@ public override string ConnectionString
157
157
}
158
158
}
159
159
160
- public override string Database => m_session . DatabaseOverride ?? m_connectionSettings . Database ;
160
+ public override string Database => m_session ? . DatabaseOverride ?? m_connectionSettings . Database ;
161
161
162
162
public override ConnectionState State => m_connectionState ;
163
163
Original file line number Diff line number Diff line change @@ -179,6 +179,21 @@ public async Task ConnectSslBadClientCertificate()
179
179
}
180
180
}
181
181
182
+ [ Fact ]
183
+ public async Task ConnectionDatabase ( )
184
+ {
185
+ var csb = AppConfig . CreateConnectionStringBuilder ( ) ;
186
+ using ( var connection = new MySqlConnection ( csb . ConnectionString ) )
187
+ {
188
+ Assert . Equal ( csb . Database , connection . Database ) ;
189
+
190
+ await connection . OpenAsync ( ) ;
191
+
192
+ Assert . Equal ( csb . Database , connection . Database ) ;
193
+ Assert . Equal ( csb . Database , await QueryCurrentDatabaseAsync ( connection ) ) ;
194
+ }
195
+ }
196
+
182
197
[ SecondaryDatabaseRequiredFact ]
183
198
public async Task ChangeDatabase ( )
184
199
{
Original file line number Diff line number Diff line change @@ -184,6 +184,21 @@ public void ConnectTimeout()
184
184
}
185
185
}
186
186
187
+ [ Fact ]
188
+ public void ConnectionDatabase ( )
189
+ {
190
+ var csb = AppConfig . CreateConnectionStringBuilder ( ) ;
191
+ using ( var connection = new MySqlConnection ( csb . ConnectionString ) )
192
+ {
193
+ Assert . Equal ( csb . Database , connection . Database ) ;
194
+
195
+ connection . Open ( ) ;
196
+
197
+ Assert . Equal ( csb . Database , connection . Database ) ;
198
+ Assert . Equal ( csb . Database , QueryCurrentDatabase ( connection ) ) ;
199
+ }
200
+ }
201
+
187
202
[ SecondaryDatabaseRequiredFact ]
188
203
public void ChangeDatabase ( )
189
204
{
You can’t perform that action at this time.
0 commit comments