From f0fd3041aa1aa0c6b89be43552a610517cbbc22a Mon Sep 17 00:00:00 2001 From: Ansis Date: Wed, 23 Oct 2024 11:27:19 +0200 Subject: [PATCH] Remove Sqlite --- UltraStar Play/Assets/Common/Common.asmdef | 2 - UltraStar Play/Assets/Common/Database.meta | 8 --- .../Common/Database/DataReaderExtensions.cs | 26 ---------- .../Database/DataReaderExtensions.cs.meta | 3 -- .../Common/Database/DbConnectionExtensions.cs | 22 -------- .../Database/DbConnectionExtensions.cs.meta | 11 ---- .../Assets/Common/Database/SqliteUtils.cs | 17 ------- .../Common/Database/SqliteUtils.cs.meta | 3 -- .../Assets/Editor/Tests/SQLiteUtilsTest.cs | 50 ------------------- .../Editor/Tests/SQLiteUtilsTest.cs.meta | 3 -- UltraStar Play/Packages/manifest.json | 1 - UltraStar Play/Packages/packages-lock.json | 7 --- 12 files changed, 153 deletions(-) delete mode 100644 UltraStar Play/Assets/Common/Database.meta delete mode 100644 UltraStar Play/Assets/Common/Database/DataReaderExtensions.cs delete mode 100644 UltraStar Play/Assets/Common/Database/DataReaderExtensions.cs.meta delete mode 100644 UltraStar Play/Assets/Common/Database/DbConnectionExtensions.cs delete mode 100644 UltraStar Play/Assets/Common/Database/DbConnectionExtensions.cs.meta delete mode 100644 UltraStar Play/Assets/Common/Database/SqliteUtils.cs delete mode 100644 UltraStar Play/Assets/Common/Database/SqliteUtils.cs.meta delete mode 100644 UltraStar Play/Assets/Editor/Tests/SQLiteUtilsTest.cs delete mode 100644 UltraStar Play/Assets/Editor/Tests/SQLiteUtilsTest.cs.meta diff --git a/UltraStar Play/Assets/Common/Common.asmdef b/UltraStar Play/Assets/Common/Common.asmdef index f9f099cb8..c68dbf118 100644 --- a/UltraStar Play/Assets/Common/Common.asmdef +++ b/UltraStar Play/Assets/Common/Common.asmdef @@ -21,7 +21,6 @@ "com.achimmihca.simplehttpserverforunity", "com.achimmihca.scenechangeanimations", "com.achimmihca.portaudioforunity", - "com.achimmihca.sqliteunity", "playshared", "playsharedui", "SpleeterSharp", @@ -44,7 +43,6 @@ "HtmlAgilityPack.dll", "LibVLCSharp.dll", "Mono.CSharp.dll", - "Mono.Data.Sqlite.dll", "ICSharpCode.SharpZipLib.dll", "WindowsInput.dll", "Newtonsoft.Json.dll" diff --git a/UltraStar Play/Assets/Common/Database.meta b/UltraStar Play/Assets/Common/Database.meta deleted file mode 100644 index 62b382969..000000000 --- a/UltraStar Play/Assets/Common/Database.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 21a7a04e8ee13da4dabcb334be8cec9f -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/UltraStar Play/Assets/Common/Database/DataReaderExtensions.cs b/UltraStar Play/Assets/Common/Database/DataReaderExtensions.cs deleted file mode 100644 index c28e089e8..000000000 --- a/UltraStar Play/Assets/Common/Database/DataReaderExtensions.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System.Collections.Generic; -using System.Data; -using System.Linq; - -public static class DataReaderExtensions -{ - public static List> ToDictionaryList(this IDataReader reader) - { - List> result = new(); - while (reader.Read()) - { - Dictionary dictionary = Enumerable.Range(0, reader.FieldCount) - .ToDictionary(reader.GetName, reader.GetValue); - result.Add(dictionary); - } - return result; - } - - public static List ToList(this IDataReader reader) - { - List> dictionaryList = reader.ToDictionaryList(); - // Use JSON serialization to get the desired type - string json = JsonConverter.ToJson(dictionaryList); - return JsonConverter.FromJson>(json); - } -} diff --git a/UltraStar Play/Assets/Common/Database/DataReaderExtensions.cs.meta b/UltraStar Play/Assets/Common/Database/DataReaderExtensions.cs.meta deleted file mode 100644 index b1f287eed..000000000 --- a/UltraStar Play/Assets/Common/Database/DataReaderExtensions.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 74663f9680384953a976ff9ced30315c -timeCreated: 1695032990 \ No newline at end of file diff --git a/UltraStar Play/Assets/Common/Database/DbConnectionExtensions.cs b/UltraStar Play/Assets/Common/Database/DbConnectionExtensions.cs deleted file mode 100644 index 0fada3dfe..000000000 --- a/UltraStar Play/Assets/Common/Database/DbConnectionExtensions.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System.Data; - -// Disable warning about fields that are never assigned, their values are injected. -#pragma warning disable CS0649 - -public static class DbConnectionExtensions -{ - public static int ExecuteNonQuery(this IDbConnection dbConnection, string command) - { - IDbCommand dbCommand = dbConnection.CreateCommand(); - dbCommand.CommandText = command; - return dbCommand.ExecuteNonQuery(); - } - - public static IDataReader ExecuteQuery(this IDbConnection dbConnection, string query) - { - IDbCommand dbCommand = dbConnection.CreateCommand(); - dbCommand.CommandText = query; - IDataReader reader = dbCommand.ExecuteReader(); - return reader; - } -} diff --git a/UltraStar Play/Assets/Common/Database/DbConnectionExtensions.cs.meta b/UltraStar Play/Assets/Common/Database/DbConnectionExtensions.cs.meta deleted file mode 100644 index 2d154cd9b..000000000 --- a/UltraStar Play/Assets/Common/Database/DbConnectionExtensions.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 4a0164cfc95ae5341af8b58ade0aed60 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/UltraStar Play/Assets/Common/Database/SqliteUtils.cs b/UltraStar Play/Assets/Common/Database/SqliteUtils.cs deleted file mode 100644 index 86af0f0b5..000000000 --- a/UltraStar Play/Assets/Common/Database/SqliteUtils.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System.Data; -using Mono.Data.Sqlite; - -public static class SqliteUtils -{ - public static IDbConnection OpenSqliteConnectionToFile(string filePath) - { - return OpenSqliteConnection($"URI=file:{filePath}"); - } - - public static IDbConnection OpenSqliteConnection(string connectionString) - { - IDbConnection dbConnection = new SqliteConnection(connectionString); - dbConnection.Open(); - return dbConnection; - } -} diff --git a/UltraStar Play/Assets/Common/Database/SqliteUtils.cs.meta b/UltraStar Play/Assets/Common/Database/SqliteUtils.cs.meta deleted file mode 100644 index b265d6991..000000000 --- a/UltraStar Play/Assets/Common/Database/SqliteUtils.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: aa4729dfcc64498c8f9f39ebb13f1af1 -timeCreated: 1695029519 \ No newline at end of file diff --git a/UltraStar Play/Assets/Editor/Tests/SQLiteUtilsTest.cs b/UltraStar Play/Assets/Editor/Tests/SQLiteUtilsTest.cs deleted file mode 100644 index ba4e57d0c..000000000 --- a/UltraStar Play/Assets/Editor/Tests/SQLiteUtilsTest.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System.Collections.Generic; -using System.Data; -using NUnit.Framework; -using UnityEngine; - -public class SQLiteUtilsTest -{ - [Test] - public void CreateDatabaseInsertAndRead() - { - string dbPath = $"{Application.persistentDataPath}/SQLiteTestDatabase.db"; - - // Delete old database - FileUtils.Delete(dbPath); - - // Open connection, auto close via using statement - using IDbConnection dbConnection = SqliteUtils.OpenSqliteConnectionToFile(dbPath); - - // Insert data - dbConnection.ExecuteNonQuery("CREATE TABLE IF NOT EXISTS my_table (id INTEGER PRIMARY KEY, name STRING, age INTEGER)"); - dbConnection.ExecuteNonQuery("INSERT INTO my_table (id, name, age) VALUES (1, 'Alice', 42)"); - dbConnection.ExecuteNonQuery("INSERT INTO my_table (id, name, age) VALUES (2, 'Bob', 33)"); - - // Read data - IDataReader dataReader = dbConnection.ExecuteQuery("SELECT * FROM my_table"); - List records = dataReader.ToList(); - - // Assert data is as expected - if (records.Count != 2) - { - Assert.Fail("Unexpected number of rows returned"); - } - PersonDb firstRecord = records[0]; - Assert.AreEqual(1, firstRecord.id); - Assert.AreEqual("Alice", firstRecord.name); - Assert.AreEqual(42, firstRecord.age); - - PersonDb secondRecord = records[1]; - Assert.AreEqual(2, secondRecord.id); - Assert.AreEqual("Bob", secondRecord.name); - Assert.AreEqual(33, secondRecord.age); - } -} - -public class PersonDb -{ - public long id; - public string name; - public long age; -} diff --git a/UltraStar Play/Assets/Editor/Tests/SQLiteUtilsTest.cs.meta b/UltraStar Play/Assets/Editor/Tests/SQLiteUtilsTest.cs.meta deleted file mode 100644 index 123848f2e..000000000 --- a/UltraStar Play/Assets/Editor/Tests/SQLiteUtilsTest.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 2a4b1359be78464aa906bbe91aedac1f -timeCreated: 1695030180 \ No newline at end of file diff --git a/UltraStar Play/Packages/manifest.json b/UltraStar Play/Packages/manifest.json index 81204f929..b0a138031 100644 --- a/UltraStar Play/Packages/manifest.json +++ b/UltraStar Play/Packages/manifest.json @@ -5,7 +5,6 @@ "com.achimmihca.protrans": "https://github.com/achimmihca/ProTrans.git?path=ProTrans/Packages/com.achimmihca.ProTrans#1506e8dbedb71fefe47c1ffed9ea00c96e37a385", "com.achimmihca.scenechangeanimations": "https://github.com/achimmihca/SceneChangeAnimations.git?path=SceneChangeAnimations/Packages/com.achimmihca.scenechangeanimations#v1.0.0", "com.achimmihca.simplehttpserverforunity": "https://github.com/achimmihca/SimpleHttpServerForUnity.git?path=SimpleHttpServerForUnity/Packages/com.achimmihca.simplehttpserverforunity#5b6e02e899a69af2aa5eb22d49927697bfbd8a38", - "com.achimmihca.sqliteunity": "https://github.com/achimmihca/SQLiteUnity.git?path=SQLiteUnity/Packages/com.achimmihca.sqliteunity#654876bc42a72eb46feb045d86e3b7ea01fb50fc", "com.achimmihca.uniinject": "https://github.com/achimmihca/UniInject.git?path=UniInject/Packages/com.achimmihca.uniinject#54c45dd7ff297312d743443d2e525d5f12690828", "com.achimmihca.utfunknownunity": "https://github.com/achimmihca/UTF-Unknown-Unity.git?path=UTF-Unknown-Unity/Packages/com.achimmihca.utfunknownunity#v1.0.1", "com.beatwaves.responsible": "https://github.com/sbergen/Responsible.git?path=/com.beatwaves.responsible#v4.4.0", diff --git a/UltraStar Play/Packages/packages-lock.json b/UltraStar Play/Packages/packages-lock.json index 1b6f124e7..de400df71 100644 --- a/UltraStar Play/Packages/packages-lock.json +++ b/UltraStar Play/Packages/packages-lock.json @@ -35,13 +35,6 @@ "dependencies": {}, "hash": "5b6e02e899a69af2aa5eb22d49927697bfbd8a38" }, - "com.achimmihca.sqliteunity": { - "version": "https://github.com/achimmihca/SQLiteUnity.git?path=SQLiteUnity/Packages/com.achimmihca.sqliteunity#654876bc42a72eb46feb045d86e3b7ea01fb50fc", - "depth": 0, - "source": "git", - "dependencies": {}, - "hash": "654876bc42a72eb46feb045d86e3b7ea01fb50fc" - }, "com.achimmihca.uniinject": { "version": "https://github.com/achimmihca/UniInject.git?path=UniInject/Packages/com.achimmihca.uniinject#54c45dd7ff297312d743443d2e525d5f12690828", "depth": 0,