Skip to content

Commit

Permalink
force UseAffectedRows=false. fixes #93 (#100)
Browse files Browse the repository at this point in the history
  • Loading branch information
caleblloyd authored and yukozh committed Oct 29, 2016
1 parent 6fdc071 commit 3b60071
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ public static DbContextOptionsBuilder UseMySql(

var csb = new MySqlConnectionStringBuilder(connectionString)
{
AllowUserVariables = true
AllowUserVariables = true,
UseAffectedRows = false
};
connectionString = csb.ConnectionString;

Expand All @@ -47,7 +48,8 @@ public static DbContextOptionsBuilder UseMySql(

var csb = new MySqlConnectionStringBuilder(connection.ConnectionString)
{
AllowUserVariables = true
AllowUserVariables = true,
UseAffectedRows = false
};

connection.ConnectionString = csb.ConnectionString;
Expand Down
2 changes: 1 addition & 1 deletion src/Pomelo.EntityFrameworkCore.MySql/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

"dependencies": {
"Microsoft.EntityFrameworkCore.Relational": "1.0.1",
"MySqlConnector": "0.6.0-*",
"MySqlConnector": "0.6.*",
"Pomelo.JsonObject": "1.0.0-*"
},

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System.Threading.Tasks;
using Pomelo.EntityFrameworkCore.MySql.PerfTests.Models;
using Xunit;

namespace Pomelo.EntityFrameworkCore.MySql.PerfTests.Tests.Connection
{
public class ConnectionTest
{

[Fact]
public async Task AffectedRowsFalse()
{
var title = "test";
var blog = new Blog{ Title = title };
using (var db = new AppDb())
{
db.Blogs.Add(blog);
await db.SaveChangesAsync();
}
Assert.True(blog.Id > 0);

// this will throw a DbUpdateConcurrencyException if UseAffectedRows=true
var sameBlog = new Blog { Id = blog.Id, Title = title };
using (var db = new AppDb())
{
db.Blogs.Update(sameBlog);
await db.SaveChangesAsync();
}
Assert.Equal(blog.Id, sameBlog.Id);
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public void Can_create_master_connection_string()
{
using (var master = connection.CreateMasterConnection())
{
Assert.Equal(@"Server=localhost;Port=3306;Database=mysql;User Id=root;Password=Password12!;AllowUserVariables=True;Pooling=False", master.ConnectionString);
Assert.Equal(@"Server=localhost;Port=3306;Database=mysql;User Id=root;Password=Password12!;AllowUserVariables=True;Use Affected Rows=False;Pooling=False", master.ConnectionString);
}
}
}
Expand Down

0 comments on commit 3b60071

Please sign in to comment.