Quantcast
Channel: MySQL Forums - Connector/NET and C#, Mono, .Net
Viewing all articles
Browse latest Browse all 1451

ON DUPLICATE KEY UPDATE - Always returns positive integer (no replies)

$
0
0
- Running "on duplicate key update" query with .Net Connector always returns positive integer even when the row does not change.
- However same query works as expected in MySQL Console and MySQL Workbench and returns "0 rows affected" when there is no change

This seems like a bug to me. Any ideas?

Sample Query:
insert into test (k,v) values ('testkey',123) on duplicate key update v=values(v);

Test Table:
CREATE TABLE `test` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`k` varchar(45) DEFAULT NULL,
`v` varchar(45) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `icol_UNIQUE` (`k`)
) ENGINE=MyISAM AUTO_INCREMENT=7 DEFAULT CHARSET=utf8;


C# Test Code:
using (var con = new MySqlConnection("Database=mydb;Data Source=localhost;User Id=root;Password=mypass;CharSet=utf8;"))
{
con.Open();
var cmd = new MySqlCommand("insert into test (k,v) values ('testkey',123) on duplicate key update v=values(v)", con);
var rows = cmd.ExecuteNonQuery();

Console.WriteLine(rows); // rows is always 2 OR 1
}

NOTES:

- I am using MySql .Net Connector 6.9.9. Same issue exists in 6.9.8
- All database/connection charset/collation settings are utf8

Viewing all articles
Browse latest Browse all 1451

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>