From 4260d1619fd1825bdaaa7b5f6fb342828660b3e9 Mon Sep 17 00:00:00 2001 From: NetDwarf Date: Fri, 22 Oct 2021 22:44:07 +0200 Subject: [PATCH 1/2] Add Tests for ISO88591 and cp1252 special characters --- .../Database/DatabaseTests.cs | 35 +++++++++++++++++++ .../IntegrationTests/Database/MySQLDBSetUp.cs | 2 +- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/Tests/IntegrationTests/Database/DatabaseTests.cs b/Tests/IntegrationTests/Database/DatabaseTests.cs index 3c5386deb1..5ab7b162cf 100644 --- a/Tests/IntegrationTests/Database/DatabaseTests.cs +++ b/Tests/IntegrationTests/Database/DatabaseTests.cs @@ -1157,5 +1157,40 @@ public void TestTableRelationWithPrecacheAndPrimaryRemote() Assert.IsNull(relretrieve.Entry, "Relations Test With Precache and Primary should return null value for null local field relation..."); } + + [Test] + public void SelectObject_TestFieldContainsSpecialISO88591signs_TestfieldIsUnaltered() + { + Database.RegisterDataObject(typeof(TestTable)); + var dataObject = new TestTable(); + dataObject.TestField = "¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ"; + + AddOrReplaceObject(dataObject); + + var actual = Database.FindObjectByKey(dataObject.ObjectId).TestField; + var expected = dataObject.TestField; + Assert.AreEqual(expected, actual); + } + + [Test] + public void SelectObject_TestFieldContainsSpecialCp1252signs_TestfieldIsUnaltered() + { + Database.RegisterDataObject(typeof(TestTable)); + var dataObject = new TestTable(); + dataObject.TestField = "€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ"; + + AddOrReplaceObject(dataObject); + + var actual = Database.FindObjectByKey(dataObject.ObjectId).TestField; + var expected = dataObject.TestField; + Assert.AreEqual(expected, actual); + } + + private void AddOrReplaceObject(T dataObject) where T : DataObject + { + var dataObjectFromDatabase = Database.FindObjectByKey(dataObject.ObjectId); + if (dataObjectFromDatabase != null) Database.DeleteObject(dataObject); + Database.AddObject(dataObject); + } } } diff --git a/Tests/IntegrationTests/Database/MySQLDBSetUp.cs b/Tests/IntegrationTests/Database/MySQLDBSetUp.cs index d250bfe897..4da92618cd 100644 --- a/Tests/IntegrationTests/Database/MySQLDBSetUp.cs +++ b/Tests/IntegrationTests/Database/MySQLDBSetUp.cs @@ -27,7 +27,7 @@ namespace DOL.Integration.Database.MySQL { - [SetUpFixture] + [SetUpFixture, Explicit] public class MySQLDBSetUp { public MySQLDBSetUp() From a93ec1323e7c0c17f857274c414708bbbf8377f9 Mon Sep 17 00:00:00 2001 From: NetDwarf Date: Fri, 22 Oct 2021 22:49:37 +0200 Subject: [PATCH 2/2] Replace MySql.Data with MySqlConnector Fix MariaDB 10.6 Fix utf8 databases with special chars --- DOLDatabase/DOLDatabase.csproj | 2 +- DOLDatabase/Handlers/MySQLObjectDatabase.cs | 2 +- Net5/DOLDatabase/DOLDatabase.csproj | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/DOLDatabase/DOLDatabase.csproj b/DOLDatabase/DOLDatabase.csproj index 9d6c383c12..43125949c9 100644 --- a/DOLDatabase/DOLDatabase.csproj +++ b/DOLDatabase/DOLDatabase.csproj @@ -60,7 +60,7 @@ - + diff --git a/DOLDatabase/Handlers/MySQLObjectDatabase.cs b/DOLDatabase/Handlers/MySQLObjectDatabase.cs index 234192bf5e..b05b0ed5c2 100644 --- a/DOLDatabase/Handlers/MySQLObjectDatabase.cs +++ b/DOLDatabase/Handlers/MySQLObjectDatabase.cs @@ -23,7 +23,7 @@ using System.Data; using System.Data.Common; -using MySql.Data.MySqlClient; +using MySqlConnector; using DOL.Database.Connection; diff --git a/Net5/DOLDatabase/DOLDatabase.csproj b/Net5/DOLDatabase/DOLDatabase.csproj index b9aea537ce..8025bb1c6c 100644 --- a/Net5/DOLDatabase/DOLDatabase.csproj +++ b/Net5/DOLDatabase/DOLDatabase.csproj @@ -40,7 +40,7 @@ - +