Skip to content

Commit 0896e19

Browse files
committed
Set UseAffectedRows=false by default. Fixes #600
1 parent 18957cb commit 0896e19

File tree

6 files changed

+9
-19
lines changed

6 files changed

+9
-19
lines changed

.ci/config/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"Data": {
3-
"ConnectionString": "server=127.0.0.1;user id=mysqltest;password='test;key=\"val';port=3306;database=mysqltest;ssl mode=none;Use Affected Rows=true;DefaultCommandTimeout=3600",
3+
"ConnectionString": "server=127.0.0.1;user id=mysqltest;password='test;key=\"val';port=3306;database=mysqltest;ssl mode=none;DefaultCommandTimeout=3600",
44
"PasswordlessUser": "no_password",
55
"SecondaryDatabase": "testdb2",
66
"UnsupportedFeatures": "RsaEncryption,CachingSha2Password,Tls12,UuidToBin",

docs/content/connection-options.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,8 +340,8 @@ These are the other options that MySqlConnector supports. They are set to sensib
340340
</tr>
341341
<tr>
342342
<td>Use Affected Rows, UseAffectedRows</td>
343-
<td>true</td>
344-
<td>When false, the connection reports found rows instead of changed (affected) rows.</td>
343+
<td>false</td>
344+
<td>When <code>false</code> (default), the connection reports found rows instead of changed (affected) rows. Set to <code>true</code> to report only the number of rows actually changed by <code>UPDATE</code> or <code>INSERT … ON DUPLICATE KEY UPDATE</code> statements.</td>
345345
</tr>
346346
<tr>
347347
<td>Use XA Transactions, UseXaTransactions</td>

docs/content/tutorials/migrating-from-connector-net.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,6 @@ MySqlConnector has some different default connection string options:
5353
<td>(not configurable)</td>
5454
<td>Specify a file containing the server’s RSA public key to allow <code>sha256_password</code> authentication over an insecure connection.</td>
5555
</tr>
56-
<tr>
57-
<td><code>UseAffectedRows</code></td>
58-
<td>Default is <code>true</code></td>
59-
<td>Default is <code>false</code></td>
60-
<td>This also affects the behavior of the <code>ROW_COUNT</code> function. <code>UseAffectedRows=true</code> is the default in most other languages (C++, PHP, others)</td>
61-
</tr>
6256
</table>
6357

6458
Some connection string options that are supported in Connector/NET are not supported in MySqlConnector. For a full list of options that are

src/MySqlConnector/MySql.Data.MySqlClient/MySqlConnectionStringBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ static MySqlConnectionStringOption()
589589

590590
AddOption(UseAffectedRows = new MySqlConnectionStringOption<bool>(
591591
keys: new[] { "Use Affected Rows", "UseAffectedRows" },
592-
defaultValue: true));
592+
defaultValue: false));
593593

594594
AddOption(UseCompression = new MySqlConnectionStringOption<bool>(
595595
keys: new[] { "Compress", "Use Compression", "UseCompression" },

tests/MySqlConnector.Tests/MySqlConnectionStringBuilderTests.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,7 @@ public void Defaults()
6363
Assert.True(csb.TreatTinyAsBoolean);
6464
Assert.False(csb.UseCompression);
6565
Assert.Equal("", csb.UserID);
66-
#if BASELINE
6766
Assert.False(csb.UseAffectedRows);
68-
#else
69-
Assert.True(csb.UseAffectedRows);
70-
#endif
7167
#if !BASELINE
7268
Assert.True(csb.UseXaTransactions);
7369
#endif
@@ -126,7 +122,7 @@ public void ParseConnectionString()
126122
"Treat Tiny As Boolean=false;" +
127123
"ssl mode=verifyca;" +
128124
"Uid=username;" +
129-
"useaffectedrows=false"
125+
"useaffectedrows=true"
130126
};
131127
Assert.True(csb.AllowPublicKeyRetrieval);
132128
Assert.True(csb.AllowUserVariables);
@@ -174,7 +170,7 @@ public void ParseConnectionString()
174170
Assert.Equal("db-server", csb.Server);
175171
Assert.False(csb.TreatTinyAsBoolean);
176172
Assert.Equal(MySqlSslMode.VerifyCA, csb.SslMode);
177-
Assert.False(csb.UseAffectedRows);
173+
Assert.True(csb.UseAffectedRows);
178174
Assert.True(csb.UseCompression);
179175
Assert.Equal("username", csb.UserID);
180176
}

tests/SideBySide/UpdateTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public void Dispose()
2323
[InlineData(1, 2)]
2424
[InlineData(2, 1)]
2525
[InlineData(3, 0)]
26-
[InlineData(4, 0)]
26+
[InlineData(4, 1)]
2727
public async Task UpdateRowsExecuteReader(int oldValue, int expectedRowsUpdated)
2828
{
2929
using (var cmd = m_database.Connection.CreateCommand())
@@ -60,7 +60,7 @@ public async Task UpdateRowsExecuteReader(int oldValue, int expectedRowsUpdated)
6060
[InlineData(1, 2)]
6161
[InlineData(2, 1)]
6262
[InlineData(3, 0)]
63-
[InlineData(4, 0)]
63+
[InlineData(4, 1)]
6464
public async Task UpdateRowsExecuteNonQuery(int oldValue, int expectedRowsUpdated)
6565
{
6666
using (var cmd = m_database.Connection.CreateCommand())
@@ -93,7 +93,7 @@ public async Task UpdateRowsExecuteNonQuery(int oldValue, int expectedRowsUpdate
9393
[InlineData(1, 2)]
9494
[InlineData(2, 1)]
9595
[InlineData(3, 0)]
96-
[InlineData(4, 0)]
96+
[InlineData(4, 1)]
9797
public void UpdateRowsDapper(int oldValue, int expectedRowsUpdated)
9898
{
9999
using (var cmd = m_database.Connection.CreateCommand())

0 commit comments

Comments
 (0)