diff --git a/SQLite.sln b/SQLite.sln index 8d3b5693..108ca76b 100644 --- a/SQLite.sln +++ b/SQLite.sln @@ -1,117 +1,149 @@  -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SQLite.Tests", "tests\SQLite.Tests.csproj", "{6947A8F1-99BE-4DD1-AD4D-D89425CE67A2}" -EndProject +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30011.22 +MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{A0E59A10-7BD0-4554-B133-66FA850159BE}" ProjectSection(SolutionItems) = preProject - sqlite-net-pcl.nuspec = sqlite-net-pcl.nuspec - sqlite-net.nuspec = sqlite-net.nuspec Makefile = Makefile + README.md = README.md sqlite-net-base.nuspec = sqlite-net-base.nuspec + sqlite-net-pcl.nuspec = sqlite-net-pcl.nuspec sqlite-net-sqlcipher.nuspec = sqlite-net-sqlcipher.nuspec - README.md = README.md + sqlite-net.nuspec = sqlite-net.nuspec EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{FECC0E44-E626-49CB-BD8B-0CFBD93FBEFF}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SQLiteTestsiOS", "tests\SQLite.Tests.iOS\SQLiteTestsiOS.csproj", "{81850129-71C3-40C7-A48B-AA5D2C2E365E}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SQLite-net-std", "nuget\SQLite-net-std\SQLite-net-std.csproj", "{081D08D6-10F1-431B-88FE-469FD9FE898C}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SQLite-net-std", "nuget\SQLite-net-std\SQLite-net-std.csproj", "{081D08D6-10F1-431B-88FE-469FD9FE898C}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ApiDiff", "tests\ApiDiff\ApiDiff.csproj", "{1DEF735C-B973-4ED9-8446-7FFA6D0B410B}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ApiDiff", "tests\ApiDiff\ApiDiff.csproj", "{1DEF735C-B973-4ED9-8446-7FFA6D0B410B}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SQLite-net-base", "nuget\SQLite-net-base\SQLite-net-base.csproj", "{53D1953C-3641-47D0-BE08-14DB853CC576}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SQLite-net-base", "nuget\SQLite-net-base\SQLite-net-base.csproj", "{53D1953C-3641-47D0-BE08-14DB853CC576}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SQLite-net-sqlcipher", "nuget\SQLite-net-sqlcipher\SQLite-net-sqlcipher.csproj", "{59DB03EF-E28D-431E-9058-74AF316800EE}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SQLite-net-sqlcipher", "nuget\SQLite-net-sqlcipher\SQLite-net-sqlcipher.csproj", "{59DB03EF-E28D-431E-9058-74AF316800EE}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SQLite.Tests", "tests\SQLite.Tests\SQLite.Tests.csproj", "{4E7A9F11-9742-4622-9AA8-9B1F4CFD72CB}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU + Debug|iPhone = Debug|iPhone Debug|iPhoneSimulator = Debug|iPhoneSimulator + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU Release|iPhone = Release|iPhone Release|iPhoneSimulator = Release|iPhoneSimulator - Debug|iPhone = Debug|iPhone + Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {6947A8F1-99BE-4DD1-AD4D-D89425CE67A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6947A8F1-99BE-4DD1-AD4D-D89425CE67A2}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6947A8F1-99BE-4DD1-AD4D-D89425CE67A2}.Release|Any CPU.ActiveCfg = Release|Any CPU - {6947A8F1-99BE-4DD1-AD4D-D89425CE67A2}.Release|Any CPU.Build.0 = Release|Any CPU - {6947A8F1-99BE-4DD1-AD4D-D89425CE67A2}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU - {6947A8F1-99BE-4DD1-AD4D-D89425CE67A2}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU - {6947A8F1-99BE-4DD1-AD4D-D89425CE67A2}.Release|iPhone.ActiveCfg = Release|Any CPU - {6947A8F1-99BE-4DD1-AD4D-D89425CE67A2}.Release|iPhone.Build.0 = Release|Any CPU - {6947A8F1-99BE-4DD1-AD4D-D89425CE67A2}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU - {6947A8F1-99BE-4DD1-AD4D-D89425CE67A2}.Release|iPhoneSimulator.Build.0 = Release|Any CPU - {6947A8F1-99BE-4DD1-AD4D-D89425CE67A2}.Debug|iPhone.ActiveCfg = Debug|Any CPU - {6947A8F1-99BE-4DD1-AD4D-D89425CE67A2}.Debug|iPhone.Build.0 = Debug|Any CPU {81850129-71C3-40C7-A48B-AA5D2C2E365E}.Debug|Any CPU.ActiveCfg = Debug|iPhoneSimulator {81850129-71C3-40C7-A48B-AA5D2C2E365E}.Debug|Any CPU.Build.0 = Debug|iPhoneSimulator - {81850129-71C3-40C7-A48B-AA5D2C2E365E}.Release|Any CPU.ActiveCfg = Release|iPhone - {81850129-71C3-40C7-A48B-AA5D2C2E365E}.Release|Any CPU.Build.0 = Release|iPhone + {81850129-71C3-40C7-A48B-AA5D2C2E365E}.Debug|iPhone.ActiveCfg = Debug|iPhone + {81850129-71C3-40C7-A48B-AA5D2C2E365E}.Debug|iPhone.Build.0 = Debug|iPhone {81850129-71C3-40C7-A48B-AA5D2C2E365E}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator {81850129-71C3-40C7-A48B-AA5D2C2E365E}.Debug|iPhoneSimulator.Build.0 = Debug|iPhoneSimulator + {81850129-71C3-40C7-A48B-AA5D2C2E365E}.Debug|x86.ActiveCfg = Debug|iPhone + {81850129-71C3-40C7-A48B-AA5D2C2E365E}.Release|Any CPU.ActiveCfg = Release|iPhone + {81850129-71C3-40C7-A48B-AA5D2C2E365E}.Release|Any CPU.Build.0 = Release|iPhone {81850129-71C3-40C7-A48B-AA5D2C2E365E}.Release|iPhone.ActiveCfg = Release|iPhone {81850129-71C3-40C7-A48B-AA5D2C2E365E}.Release|iPhone.Build.0 = Release|iPhone {81850129-71C3-40C7-A48B-AA5D2C2E365E}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator {81850129-71C3-40C7-A48B-AA5D2C2E365E}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator - {81850129-71C3-40C7-A48B-AA5D2C2E365E}.Debug|iPhone.ActiveCfg = Debug|iPhone - {81850129-71C3-40C7-A48B-AA5D2C2E365E}.Debug|iPhone.Build.0 = Debug|iPhone + {81850129-71C3-40C7-A48B-AA5D2C2E365E}.Release|x86.ActiveCfg = Release|iPhoneSimulator {081D08D6-10F1-431B-88FE-469FD9FE898C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {081D08D6-10F1-431B-88FE-469FD9FE898C}.Debug|Any CPU.Build.0 = Debug|Any CPU - {081D08D6-10F1-431B-88FE-469FD9FE898C}.Release|Any CPU.ActiveCfg = Release|Any CPU - {081D08D6-10F1-431B-88FE-469FD9FE898C}.Release|Any CPU.Build.0 = Release|Any CPU + {081D08D6-10F1-431B-88FE-469FD9FE898C}.Debug|iPhone.ActiveCfg = Debug|Any CPU + {081D08D6-10F1-431B-88FE-469FD9FE898C}.Debug|iPhone.Build.0 = Debug|Any CPU {081D08D6-10F1-431B-88FE-469FD9FE898C}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU {081D08D6-10F1-431B-88FE-469FD9FE898C}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU + {081D08D6-10F1-431B-88FE-469FD9FE898C}.Debug|x86.ActiveCfg = Debug|Any CPU + {081D08D6-10F1-431B-88FE-469FD9FE898C}.Debug|x86.Build.0 = Debug|Any CPU + {081D08D6-10F1-431B-88FE-469FD9FE898C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {081D08D6-10F1-431B-88FE-469FD9FE898C}.Release|Any CPU.Build.0 = Release|Any CPU {081D08D6-10F1-431B-88FE-469FD9FE898C}.Release|iPhone.ActiveCfg = Release|Any CPU {081D08D6-10F1-431B-88FE-469FD9FE898C}.Release|iPhone.Build.0 = Release|Any CPU {081D08D6-10F1-431B-88FE-469FD9FE898C}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU {081D08D6-10F1-431B-88FE-469FD9FE898C}.Release|iPhoneSimulator.Build.0 = Release|Any CPU - {081D08D6-10F1-431B-88FE-469FD9FE898C}.Debug|iPhone.ActiveCfg = Debug|Any CPU - {081D08D6-10F1-431B-88FE-469FD9FE898C}.Debug|iPhone.Build.0 = Debug|Any CPU + {081D08D6-10F1-431B-88FE-469FD9FE898C}.Release|x86.ActiveCfg = Release|Any CPU + {081D08D6-10F1-431B-88FE-469FD9FE898C}.Release|x86.Build.0 = Release|Any CPU {1DEF735C-B973-4ED9-8446-7FFA6D0B410B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {1DEF735C-B973-4ED9-8446-7FFA6D0B410B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {1DEF735C-B973-4ED9-8446-7FFA6D0B410B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {1DEF735C-B973-4ED9-8446-7FFA6D0B410B}.Release|Any CPU.Build.0 = Release|Any CPU + {1DEF735C-B973-4ED9-8446-7FFA6D0B410B}.Debug|iPhone.ActiveCfg = Debug|Any CPU + {1DEF735C-B973-4ED9-8446-7FFA6D0B410B}.Debug|iPhone.Build.0 = Debug|Any CPU {1DEF735C-B973-4ED9-8446-7FFA6D0B410B}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU {1DEF735C-B973-4ED9-8446-7FFA6D0B410B}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU + {1DEF735C-B973-4ED9-8446-7FFA6D0B410B}.Debug|x86.ActiveCfg = Debug|Any CPU + {1DEF735C-B973-4ED9-8446-7FFA6D0B410B}.Debug|x86.Build.0 = Debug|Any CPU + {1DEF735C-B973-4ED9-8446-7FFA6D0B410B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1DEF735C-B973-4ED9-8446-7FFA6D0B410B}.Release|Any CPU.Build.0 = Release|Any CPU {1DEF735C-B973-4ED9-8446-7FFA6D0B410B}.Release|iPhone.ActiveCfg = Release|Any CPU {1DEF735C-B973-4ED9-8446-7FFA6D0B410B}.Release|iPhone.Build.0 = Release|Any CPU {1DEF735C-B973-4ED9-8446-7FFA6D0B410B}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU {1DEF735C-B973-4ED9-8446-7FFA6D0B410B}.Release|iPhoneSimulator.Build.0 = Release|Any CPU - {1DEF735C-B973-4ED9-8446-7FFA6D0B410B}.Debug|iPhone.ActiveCfg = Debug|Any CPU - {1DEF735C-B973-4ED9-8446-7FFA6D0B410B}.Debug|iPhone.Build.0 = Debug|Any CPU + {1DEF735C-B973-4ED9-8446-7FFA6D0B410B}.Release|x86.ActiveCfg = Release|Any CPU + {1DEF735C-B973-4ED9-8446-7FFA6D0B410B}.Release|x86.Build.0 = Release|Any CPU {53D1953C-3641-47D0-BE08-14DB853CC576}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {53D1953C-3641-47D0-BE08-14DB853CC576}.Debug|Any CPU.Build.0 = Debug|Any CPU - {53D1953C-3641-47D0-BE08-14DB853CC576}.Release|Any CPU.ActiveCfg = Release|Any CPU - {53D1953C-3641-47D0-BE08-14DB853CC576}.Release|Any CPU.Build.0 = Release|Any CPU + {53D1953C-3641-47D0-BE08-14DB853CC576}.Debug|iPhone.ActiveCfg = Debug|Any CPU + {53D1953C-3641-47D0-BE08-14DB853CC576}.Debug|iPhone.Build.0 = Debug|Any CPU {53D1953C-3641-47D0-BE08-14DB853CC576}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU {53D1953C-3641-47D0-BE08-14DB853CC576}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU + {53D1953C-3641-47D0-BE08-14DB853CC576}.Debug|x86.ActiveCfg = Debug|Any CPU + {53D1953C-3641-47D0-BE08-14DB853CC576}.Debug|x86.Build.0 = Debug|Any CPU + {53D1953C-3641-47D0-BE08-14DB853CC576}.Release|Any CPU.ActiveCfg = Release|Any CPU + {53D1953C-3641-47D0-BE08-14DB853CC576}.Release|Any CPU.Build.0 = Release|Any CPU {53D1953C-3641-47D0-BE08-14DB853CC576}.Release|iPhone.ActiveCfg = Release|Any CPU {53D1953C-3641-47D0-BE08-14DB853CC576}.Release|iPhone.Build.0 = Release|Any CPU {53D1953C-3641-47D0-BE08-14DB853CC576}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU {53D1953C-3641-47D0-BE08-14DB853CC576}.Release|iPhoneSimulator.Build.0 = Release|Any CPU - {53D1953C-3641-47D0-BE08-14DB853CC576}.Debug|iPhone.ActiveCfg = Debug|Any CPU - {53D1953C-3641-47D0-BE08-14DB853CC576}.Debug|iPhone.Build.0 = Debug|Any CPU + {53D1953C-3641-47D0-BE08-14DB853CC576}.Release|x86.ActiveCfg = Release|Any CPU + {53D1953C-3641-47D0-BE08-14DB853CC576}.Release|x86.Build.0 = Release|Any CPU {59DB03EF-E28D-431E-9058-74AF316800EE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {59DB03EF-E28D-431E-9058-74AF316800EE}.Debug|Any CPU.Build.0 = Debug|Any CPU - {59DB03EF-E28D-431E-9058-74AF316800EE}.Release|Any CPU.ActiveCfg = Release|Any CPU - {59DB03EF-E28D-431E-9058-74AF316800EE}.Release|Any CPU.Build.0 = Release|Any CPU + {59DB03EF-E28D-431E-9058-74AF316800EE}.Debug|iPhone.ActiveCfg = Debug|Any CPU + {59DB03EF-E28D-431E-9058-74AF316800EE}.Debug|iPhone.Build.0 = Debug|Any CPU {59DB03EF-E28D-431E-9058-74AF316800EE}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU {59DB03EF-E28D-431E-9058-74AF316800EE}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU + {59DB03EF-E28D-431E-9058-74AF316800EE}.Debug|x86.ActiveCfg = Debug|Any CPU + {59DB03EF-E28D-431E-9058-74AF316800EE}.Debug|x86.Build.0 = Debug|Any CPU + {59DB03EF-E28D-431E-9058-74AF316800EE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {59DB03EF-E28D-431E-9058-74AF316800EE}.Release|Any CPU.Build.0 = Release|Any CPU {59DB03EF-E28D-431E-9058-74AF316800EE}.Release|iPhone.ActiveCfg = Release|Any CPU {59DB03EF-E28D-431E-9058-74AF316800EE}.Release|iPhone.Build.0 = Release|Any CPU {59DB03EF-E28D-431E-9058-74AF316800EE}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU {59DB03EF-E28D-431E-9058-74AF316800EE}.Release|iPhoneSimulator.Build.0 = Release|Any CPU - {59DB03EF-E28D-431E-9058-74AF316800EE}.Debug|iPhone.ActiveCfg = Debug|Any CPU - {59DB03EF-E28D-431E-9058-74AF316800EE}.Debug|iPhone.Build.0 = Debug|Any CPU + {59DB03EF-E28D-431E-9058-74AF316800EE}.Release|x86.ActiveCfg = Release|Any CPU + {59DB03EF-E28D-431E-9058-74AF316800EE}.Release|x86.Build.0 = Release|Any CPU + {4E7A9F11-9742-4622-9AA8-9B1F4CFD72CB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4E7A9F11-9742-4622-9AA8-9B1F4CFD72CB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4E7A9F11-9742-4622-9AA8-9B1F4CFD72CB}.Debug|iPhone.ActiveCfg = Debug|Any CPU + {4E7A9F11-9742-4622-9AA8-9B1F4CFD72CB}.Debug|iPhone.Build.0 = Debug|Any CPU + {4E7A9F11-9742-4622-9AA8-9B1F4CFD72CB}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {4E7A9F11-9742-4622-9AA8-9B1F4CFD72CB}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU + {4E7A9F11-9742-4622-9AA8-9B1F4CFD72CB}.Debug|x86.ActiveCfg = Debug|x86 + {4E7A9F11-9742-4622-9AA8-9B1F4CFD72CB}.Debug|x86.Build.0 = Debug|x86 + {4E7A9F11-9742-4622-9AA8-9B1F4CFD72CB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4E7A9F11-9742-4622-9AA8-9B1F4CFD72CB}.Release|Any CPU.Build.0 = Release|Any CPU + {4E7A9F11-9742-4622-9AA8-9B1F4CFD72CB}.Release|iPhone.ActiveCfg = Release|Any CPU + {4E7A9F11-9742-4622-9AA8-9B1F4CFD72CB}.Release|iPhone.Build.0 = Release|Any CPU + {4E7A9F11-9742-4622-9AA8-9B1F4CFD72CB}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU + {4E7A9F11-9742-4622-9AA8-9B1F4CFD72CB}.Release|iPhoneSimulator.Build.0 = Release|Any CPU + {4E7A9F11-9742-4622-9AA8-9B1F4CFD72CB}.Release|x86.ActiveCfg = Release|x86 + {4E7A9F11-9742-4622-9AA8-9B1F4CFD72CB}.Release|x86.Build.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution - {6947A8F1-99BE-4DD1-AD4D-D89425CE67A2} = {FECC0E44-E626-49CB-BD8B-0CFBD93FBEFF} {81850129-71C3-40C7-A48B-AA5D2C2E365E} = {FECC0E44-E626-49CB-BD8B-0CFBD93FBEFF} {1DEF735C-B973-4ED9-8446-7FFA6D0B410B} = {FECC0E44-E626-49CB-BD8B-0CFBD93FBEFF} + {4E7A9F11-9742-4622-9AA8-9B1F4CFD72CB} = {FECC0E44-E626-49CB-BD8B-0CFBD93FBEFF} + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {D4EE0744-5FE6-4B59-A591-6CE6586EB6F8} EndGlobalSection GlobalSection(MonoDevelopProperties) = preSolution StartupItem = tests\SQLite.Tests.csproj diff --git a/src/SQLite.cs b/src/SQLite.cs index cbc8d22a..4c2268a5 100644 --- a/src/SQLite.cs +++ b/src/SQLite.cs @@ -210,6 +210,11 @@ public partial class SQLiteConnection : IDisposable /// public bool StoreDateTimeAsTicks { get; private set; } + /// + /// Whether to store Guid properties as strings (false) or blobs (true). The default is (false) + /// + public bool StoreGuidsAsBlobs { get; private set; } + /// /// Whether to store TimeSpan properties as ticks (true) or strings (false). /// @@ -248,11 +253,11 @@ static SQLiteConnection () /// If you use DateTimeOffset properties, it will be always stored as ticks regardingless /// the storeDateTimeAsTicks parameter. /// - public SQLiteConnection (string databasePath, bool storeDateTimeAsTicks = true) - : this (new SQLiteConnectionString (databasePath, SQLiteOpenFlags.ReadWrite | SQLiteOpenFlags.Create, storeDateTimeAsTicks)) + public SQLiteConnection(string databasePath, bool storeDateTimeAsTicks = true) + : this(new SQLiteConnectionString(databasePath, SQLiteOpenFlags.ReadWrite | SQLiteOpenFlags.Create, storeDateTimeAsTicks)) { } - + /// /// Constructs a new SQLiteConnection and opens a SQLite database specified by databasePath. /// @@ -315,6 +320,7 @@ public SQLiteConnection (SQLiteConnectionString connectionString) _open = true; StoreDateTimeAsTicks = connectionString.StoreDateTimeAsTicks; + StoreGuidsAsBlobs = connectionString.StoreGuidsAsBlobs; DateTimeStringFormat = connectionString.DateTimeStringFormat; DateTimeStyle = connectionString.DateTimeStyle; @@ -565,7 +571,7 @@ public CreateTableResult CreateTable (Type ty, CreateFlags createFlags = CreateF // Build query. var query = "create " + @virtual + "table if not exists \"" + map.TableName + "\" " + @using + "(\n"; - var decls = map.Columns.Select (p => Orm.SqlDecl (p, StoreDateTimeAsTicks, StoreTimeSpanAsTicks)); + var decls = map.Columns.Select (p => Orm.SqlDecl (p, StoreDateTimeAsTicks, StoreTimeSpanAsTicks, StoreGuidsAsBlobs)); var decl = string.Join (",\n", decls.ToArray ()); query += decl; query += ")"; @@ -831,7 +837,7 @@ void MigrateTable (TableMapping map, List existingCols) } foreach (var p in toBeAdded) { - var addCol = "alter table \"" + map.TableName + "\" add column " + Orm.SqlDecl (p, StoreDateTimeAsTicks, StoreTimeSpanAsTicks); + var addCol = "alter table \"" + map.TableName + "\" add column " + Orm.SqlDecl (p, StoreDateTimeAsTicks, StoreTimeSpanAsTicks, StoreGuidsAsBlobs); Execute (addCol); } } @@ -2115,6 +2121,7 @@ public class SQLiteConnectionString public string DatabasePath { get; } public bool StoreDateTimeAsTicks { get; } public bool StoreTimeSpanAsTicks { get; } + public bool StoreGuidsAsBlobs { get; set; } public string DateTimeStringFormat { get; } public System.Globalization.DateTimeStyles DateTimeStyle { get; } public object Key { get; } @@ -2153,8 +2160,13 @@ public static bool IsInMemoryPath(string databasePath) /// If you use DateTimeOffset properties, it will be always stored as ticks regardingless /// the storeDateTimeAsTicks parameter. /// - public SQLiteConnectionString (string databasePath, bool storeDateTimeAsTicks = true) - : this (databasePath, SQLiteOpenFlags.Create | SQLiteOpenFlags.ReadWrite, storeDateTimeAsTicks) + /// + /// Specifies whether to store Guid properties as BLOBS (true) or strings (false). + /// Storing guids as blobs has multiple benefits: Faster indexing time, smaller footprint + /// and most importantly: compatibility with Microsoft.Data.Sqlite + /// + public SQLiteConnectionString (string databasePath, bool storeDateTimeAsTicks = true, bool storeGuidsAsBlobs = false) + : this (databasePath, SQLiteOpenFlags.Create | SQLiteOpenFlags.ReadWrite, storeDateTimeAsTicks, storeGuidsAsBlobs: storeGuidsAsBlobs) { } @@ -2227,13 +2239,19 @@ public SQLiteConnectionString (string databasePath, bool storeDateTimeAsTicks, o /// only here for backwards compatibility. There is a *significant* speed advantage, with no /// down sides, when setting storeTimeSpanAsTicks = true. /// - public SQLiteConnectionString (string databasePath, SQLiteOpenFlags openFlags, bool storeDateTimeAsTicks, object key = null, Action preKeyAction = null, Action postKeyAction = null, string vfsName = null, string dateTimeStringFormat = DateTimeSqliteDefaultFormat, bool storeTimeSpanAsTicks = true) + /// + /// Specifies whether to store Guid properties as BLOBS (true) or strings (false). + /// Storing guids as blobs has multiple benefits: Faster indexing time, smaller footprint + /// and most importantly: compatibility with Microsoft.Data.Sqlite + /// + public SQLiteConnectionString (string databasePath, SQLiteOpenFlags openFlags, bool storeDateTimeAsTicks, object key = null, Action preKeyAction = null, Action postKeyAction = null, string vfsName = null, string dateTimeStringFormat = DateTimeSqliteDefaultFormat, bool storeTimeSpanAsTicks = true, bool storeGuidsAsBlobs = false) { if (key != null && !((key is byte[]) || (key is string))) throw new ArgumentException ("Encryption keys must be strings or byte arrays", nameof (key)); UniqueKey = string.Format ("{0}_{1:X8}", databasePath, (uint)openFlags); StoreDateTimeAsTicks = storeDateTimeAsTicks; + StoreGuidsAsBlobs = storeGuidsAsBlobs; StoreTimeSpanAsTicks = storeTimeSpanAsTicks; DateTimeStringFormat = dateTimeStringFormat; DateTimeStyle = "o".Equals (DateTimeStringFormat, StringComparison.OrdinalIgnoreCase) || "r".Equals (DateTimeStringFormat, StringComparison.OrdinalIgnoreCase) ? System.Globalization.DateTimeStyles.RoundtripKind : System.Globalization.DateTimeStyles.None; @@ -2632,9 +2650,9 @@ public static Type GetType (object obj) return obj.GetType (); } - public static string SqlDecl (TableMapping.Column p, bool storeDateTimeAsTicks, bool storeTimeSpanAsTicks) + public static string SqlDecl (TableMapping.Column p, bool storeDateTimeAsTicks, bool storeTimeSpanAsTicks, bool storeGuidsAsBlobs) { - string decl = "\"" + p.Name + "\" " + SqlType (p, storeDateTimeAsTicks, storeTimeSpanAsTicks) + " "; + string decl = "\"" + p.Name + "\" " + SqlType (p, storeDateTimeAsTicks, storeTimeSpanAsTicks, storeGuidsAsBlobs) + " "; if (p.IsPK) { decl += "primary key "; @@ -2652,7 +2670,7 @@ public static string SqlDecl (TableMapping.Column p, bool storeDateTimeAsTicks, return decl; } - public static string SqlType (TableMapping.Column p, bool storeDateTimeAsTicks, bool storeTimeSpanAsTicks) + public static string SqlType (TableMapping.Column p, bool storeDateTimeAsTicks, bool storeTimeSpanAsTicks, bool storeGuidsAsBlobs) { var clrType = p.ColumnType; if (clrType == typeof (Boolean) || clrType == typeof (Byte) || clrType == typeof (UInt16) || clrType == typeof (SByte) || clrType == typeof (Int16) || clrType == typeof (Int32) || clrType == typeof (UInt32) || clrType == typeof (Int64)) { @@ -2688,6 +2706,8 @@ public static string SqlType (TableMapping.Column p, bool storeDateTimeAsTicks, return "blob"; } else if (clrType == typeof (Guid)) { + if (storeGuidsAsBlobs) + return "blob"; return "varchar(36)"; } else { @@ -2956,13 +2976,13 @@ void BindAll (Sqlite3Statement stmt) b.Index = nextIdx++; } - BindParameter (stmt, b.Index, b.Value, _conn.StoreDateTimeAsTicks, _conn.DateTimeStringFormat, _conn.StoreTimeSpanAsTicks); + BindParameter (stmt, b.Index, b.Value, _conn.StoreDateTimeAsTicks, _conn.DateTimeStringFormat, _conn.StoreTimeSpanAsTicks, _conn.StoreGuidsAsBlobs); } } static IntPtr NegativePointer = new IntPtr (-1); - internal static void BindParameter (Sqlite3Statement stmt, int index, object value, bool storeDateTimeAsTicks, string dateTimeStringFormat, bool storeTimeSpanAsTicks) + internal static void BindParameter (Sqlite3Statement stmt, int index, object value, bool storeDateTimeAsTicks, string dateTimeStringFormat, bool storeTimeSpanAsTicks, bool storeGuidsAsBlobs) { if (value == null) { SQLite3.BindNull (stmt, index); @@ -3009,7 +3029,13 @@ internal static void BindParameter (Sqlite3Statement stmt, int index, object val SQLite3.BindBlob (stmt, index, (byte[])value, ((byte[])value).Length, NegativePointer); } else if (value is Guid) { - SQLite3.BindText (stmt, index, ((Guid)value).ToString (), 72, NegativePointer); + if (storeGuidsAsBlobs) { + var rawGuid = ((Guid)value).ToByteArray(); + SQLite3.BindBlob (stmt, index, rawGuid, rawGuid.Length, NegativePointer); + } + else { + SQLite3.BindText (stmt, index, ((Guid)value).ToString (), 72, NegativePointer); + } } else if (value is Uri) { SQLite3.BindText (stmt, index, ((Uri)value).ToString (), -1, NegativePointer); @@ -3136,6 +3162,10 @@ object ReadCol (Sqlite3Statement stmt, int index, SQLite3.ColType type, Type clr return SQLite3.ColumnByteArray (stmt, index); } else if (clrType == typeof (Guid)) { + if (_conn.StoreGuidsAsBlobs) { + var array = SQLite3.ColumnByteArray (stmt, index); + return new Guid (array); + } var text = SQLite3.ColumnString (stmt, index); return new Guid (text); } @@ -3198,7 +3228,7 @@ public int ExecuteNonQuery (object[] source) //bind the values. if (source != null) { for (int i = 0; i < source.Length; i++) { - SQLiteCommand.BindParameter (Statement, i + 1, source[i], Connection.StoreDateTimeAsTicks, Connection.DateTimeStringFormat, Connection.StoreTimeSpanAsTicks); + SQLiteCommand.BindParameter (Statement, i + 1, source[i], Connection.StoreDateTimeAsTicks, Connection.DateTimeStringFormat, Connection.StoreTimeSpanAsTicks, Connection.StoreGuidsAsBlobs); } } r = SQLite3.Step (Statement); diff --git a/src/SQLiteAsync.cs b/src/SQLiteAsync.cs index 93d27ff1..fa8eedf6 100644 --- a/src/SQLiteAsync.cs +++ b/src/SQLiteAsync.cs @@ -51,8 +51,13 @@ public partial class SQLiteAsyncConnection /// If you use DateTimeOffset properties, it will be always stored as ticks regardingless /// the storeDateTimeAsTicks parameter. /// - public SQLiteAsyncConnection (string databasePath, bool storeDateTimeAsTicks = true) - : this (new SQLiteConnectionString (databasePath, SQLiteOpenFlags.Create | SQLiteOpenFlags.ReadWrite | SQLiteOpenFlags.FullMutex, storeDateTimeAsTicks)) + /// + /// Specifies whether to store Guid properties as BLOBS (true) or strings (false). + /// Storing guids as blobs has multiple benefits: Faster indexing time, smaller footprint + /// and most importantly: compatibility with Microsoft.Data.Sqlite + /// + public SQLiteAsyncConnection (string databasePath, bool storeDateTimeAsTicks = true, bool storeGuidsAsBlobs = false) + : this (new SQLiteConnectionString (databasePath, SQLiteOpenFlags.Create | SQLiteOpenFlags.ReadWrite | SQLiteOpenFlags.FullMutex, storeDateTimeAsTicks, storeGuidsAsBlobs: storeGuidsAsBlobs)) { } @@ -74,8 +79,13 @@ public SQLiteAsyncConnection (string databasePath, bool storeDateTimeAsTicks = t /// If you use DateTimeOffset properties, it will be always stored as ticks regardingless /// the storeDateTimeAsTicks parameter. /// - public SQLiteAsyncConnection (string databasePath, SQLiteOpenFlags openFlags, bool storeDateTimeAsTicks = true) - : this (new SQLiteConnectionString (databasePath, openFlags, storeDateTimeAsTicks)) + /// + /// Specifies whether to store Guid properties as BLOBS (true) or strings (false). + /// Storing guids as blobs has multiple benefits: Faster indexing time, smaller footprint + /// and most importantly: compatibility with Microsoft.Data.Sqlite + /// + public SQLiteAsyncConnection (string databasePath, SQLiteOpenFlags openFlags, bool storeDateTimeAsTicks = true, bool storeGuidsAsBlobs = false) + : this (new SQLiteConnectionString (databasePath, openFlags, storeDateTimeAsTicks, storeGuidsAsBlobs:storeGuidsAsBlobs)) { } @@ -143,6 +153,11 @@ public Task EnableWriteAheadLoggingAsync () /// Whether to store DateTime properties as ticks (true) or strings (false). /// public bool StoreDateTimeAsTicks => GetConnection ().StoreDateTimeAsTicks; + + /// + /// Whether to store Guid properties as strings (false) or blobs (true). The default is (false) + /// + public bool StoreGuidsAsBlobs => GetConnection ().StoreGuidsAsBlobs; /// /// Whether to store TimeSpan properties as ticks (true) or strings (false). diff --git a/tests/ApiDiff/ApiDiff.csproj b/tests/ApiDiff/ApiDiff.csproj index 577d5393..730e5989 100644 --- a/tests/ApiDiff/ApiDiff.csproj +++ b/tests/ApiDiff/ApiDiff.csproj @@ -1,42 +1,13 @@ - - + + - Debug - AnyCPU - 8.0.30703 - 2.0 - {1DEF735C-B973-4ED9-8446-7FFA6D0B410B} - Exe - ApiDiff - ApiDiff - v4.6.1 + Library + net462 + Debug;Release + latest - - true - full - false - bin\Debug - DEBUG; - prompt - 4 - true - - - true - bin\Release - prompt - 4 - true - - - - - ..\..\packages\ListDiff.1.0.7\lib\netstandard1.0\ListDiff.dll - - + - - SQLite.cs @@ -44,8 +15,15 @@ SQLiteAsync.cs + + + + 1.0.7 + + + - + - + \ No newline at end of file diff --git a/tests/ApiDiff/Properties/AssemblyInfo.cs b/tests/ApiDiff/Properties/AssemblyInfo.cs deleted file mode 100644 index 4fb893c1..00000000 --- a/tests/ApiDiff/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; - -// Information about this assembly is defined by the following attributes. -// Change them to the values specific to your project. - -[assembly: AssemblyTitle ("ApiDiff")] -[assembly: AssemblyDescription ("")] -[assembly: AssemblyConfiguration ("")] -[assembly: AssemblyCompany ("")] -[assembly: AssemblyProduct ("")] -[assembly: AssemblyCopyright ("${AuthorCopyright}")] -[assembly: AssemblyTrademark ("")] -[assembly: AssemblyCulture ("")] - -// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". -// The form "{Major}.{Minor}.*" will automatically update the build and revision, -// and "{Major}.{Minor}.{Build}.*" will update just the revision. - -// The following attributes are used to specify the signing key for the assembly, -// if desired. See the Mono documentation for more information about signing. - -//[assembly: AssemblyDelaySign(false)] -//[assembly: AssemblyKeyFile("")] diff --git a/tests/ApiDiff/packages.config b/tests/ApiDiff/packages.config deleted file mode 100644 index 48073015..00000000 --- a/tests/ApiDiff/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/tests/SQLite.Tests.csproj b/tests/SQLite.Tests.csproj deleted file mode 100644 index 0c539cfd..00000000 --- a/tests/SQLite.Tests.csproj +++ /dev/null @@ -1,94 +0,0 @@ - - - - - Debug - AnyCPU - 8.0.30703 - 2.0 - {6947A8F1-99BE-4DD1-AD4D-D89425CE67A2} - Library - SQLite.Tests - SQLite.Tests - v4.5 - - - True - full - False - bin\Debug - DEBUG - prompt - 4 - False - - - none - False - bin\Release - prompt - 4 - False - - - - - - - ..\packages\NUnit.3.12.0\lib\net45\nunit.framework.dll - - - - - - - SQLite.cs - - - - - - - - - - - - - - - - - - - - - - - - - - SQLiteAsync.cs - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/tests/SQLite.Tests.iOS/SQLiteTestsiOS.csproj b/tests/SQLite.Tests.iOS/SQLiteTestsiOS.csproj index 65c2bb89..6e50e78a 100644 --- a/tests/SQLite.Tests.iOS/SQLiteTestsiOS.csproj +++ b/tests/SQLite.Tests.iOS/SQLiteTestsiOS.csproj @@ -101,41 +101,41 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ConcurrencyTest.cs @@ -144,13 +144,13 @@ SQLiteAsync.cs - + BackupTest.cs - + ReadmeTest.cs - + QueryTest.cs diff --git a/tests/AsyncTests.cs b/tests/SQLite.Tests/AsyncTests.cs similarity index 100% rename from tests/AsyncTests.cs rename to tests/SQLite.Tests/AsyncTests.cs diff --git a/tests/BackupTest.cs b/tests/SQLite.Tests/BackupTest.cs similarity index 100% rename from tests/BackupTest.cs rename to tests/SQLite.Tests/BackupTest.cs diff --git a/tests/BooleanTest.cs b/tests/SQLite.Tests/BooleanTest.cs similarity index 100% rename from tests/BooleanTest.cs rename to tests/SQLite.Tests/BooleanTest.cs diff --git a/tests/ByteArrayTest.cs b/tests/SQLite.Tests/ByteArrayTest.cs similarity index 100% rename from tests/ByteArrayTest.cs rename to tests/SQLite.Tests/ByteArrayTest.cs diff --git a/tests/CollateTest.cs b/tests/SQLite.Tests/CollateTest.cs similarity index 100% rename from tests/CollateTest.cs rename to tests/SQLite.Tests/CollateTest.cs diff --git a/tests/ConcurrencyTest.cs b/tests/SQLite.Tests/ConcurrencyTest.cs similarity index 100% rename from tests/ConcurrencyTest.cs rename to tests/SQLite.Tests/ConcurrencyTest.cs diff --git a/tests/ContainsTest.cs b/tests/SQLite.Tests/ContainsTest.cs similarity index 100% rename from tests/ContainsTest.cs rename to tests/SQLite.Tests/ContainsTest.cs diff --git a/tests/CreateTableImplicitTest.cs b/tests/SQLite.Tests/CreateTableImplicitTest.cs similarity index 100% rename from tests/CreateTableImplicitTest.cs rename to tests/SQLite.Tests/CreateTableImplicitTest.cs diff --git a/tests/CreateTableTest.cs b/tests/SQLite.Tests/CreateTableTest.cs similarity index 100% rename from tests/CreateTableTest.cs rename to tests/SQLite.Tests/CreateTableTest.cs diff --git a/tests/DateTimeOffsetTest.cs b/tests/SQLite.Tests/DateTimeOffsetTest.cs similarity index 100% rename from tests/DateTimeOffsetTest.cs rename to tests/SQLite.Tests/DateTimeOffsetTest.cs diff --git a/tests/DateTimeTest.cs b/tests/SQLite.Tests/DateTimeTest.cs similarity index 100% rename from tests/DateTimeTest.cs rename to tests/SQLite.Tests/DateTimeTest.cs diff --git a/tests/DeleteTest.cs b/tests/SQLite.Tests/DeleteTest.cs similarity index 100% rename from tests/DeleteTest.cs rename to tests/SQLite.Tests/DeleteTest.cs diff --git a/tests/DropTableTest.cs b/tests/SQLite.Tests/DropTableTest.cs similarity index 100% rename from tests/DropTableTest.cs rename to tests/SQLite.Tests/DropTableTest.cs diff --git a/tests/EnumCacheTest.cs b/tests/SQLite.Tests/EnumCacheTest.cs similarity index 99% rename from tests/EnumCacheTest.cs rename to tests/SQLite.Tests/EnumCacheTest.cs index c6163f5d..06c95de0 100644 --- a/tests/EnumCacheTest.cs +++ b/tests/SQLite.Tests/EnumCacheTest.cs @@ -35,8 +35,8 @@ public enum TestEnumStoreAsInt Value2, Value3 - } - + } + public enum TestByteEnumStoreAsInt : byte { Value1, @@ -99,8 +99,8 @@ public void ShouldReturnTrueForEnumStoreAsInt() Assert.IsTrue(info.IsEnum); Assert.IsFalse(info.StoreAsText); Assert.IsNull(info.EnumValues); - } - + } + [Test] public void ShouldReturnTrueForByteEnumStoreAsInt() { diff --git a/tests/EnumNullableTest.cs b/tests/SQLite.Tests/EnumNullableTest.cs similarity index 100% rename from tests/EnumNullableTest.cs rename to tests/SQLite.Tests/EnumNullableTest.cs diff --git a/tests/EnumTest.cs b/tests/SQLite.Tests/EnumTest.cs similarity index 100% rename from tests/EnumTest.cs rename to tests/SQLite.Tests/EnumTest.cs diff --git a/tests/EqualsTest.cs b/tests/SQLite.Tests/EqualsTest.cs similarity index 100% rename from tests/EqualsTest.cs rename to tests/SQLite.Tests/EqualsTest.cs diff --git a/tests/ExceptionAssert.cs b/tests/SQLite.Tests/ExceptionAssert.cs similarity index 100% rename from tests/ExceptionAssert.cs rename to tests/SQLite.Tests/ExceptionAssert.cs diff --git a/tests/GuidTests.cs b/tests/SQLite.Tests/GuidTests.cs similarity index 100% rename from tests/GuidTests.cs rename to tests/SQLite.Tests/GuidTests.cs diff --git a/tests/SQLite.Tests/GuidsAsBlobsTest.cs b/tests/SQLite.Tests/GuidsAsBlobsTest.cs new file mode 100644 index 00000000..1d4f7886 --- /dev/null +++ b/tests/SQLite.Tests/GuidsAsBlobsTest.cs @@ -0,0 +1,204 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +#if NETFX_CORE +using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; +using SetUp = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestInitializeAttribute; +using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute; +using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute; +#else +using NUnit.Framework; +#endif + + +namespace SQLite.Tests +{ + [TestFixture] + public class GuidAsBlobsTests + { + public class TestObj + { + [PrimaryKey] + public Guid Id { get; set; } + public String Text { get; set; } + + public override string ToString() + { + return string.Format("[TestObj: Id={0}, Text={1}]", Id, Text); + } + + } + + public class TestDb : SQLiteConnection + { + public TestDb(string path) + : base(new SQLiteConnectionString (path, storeGuidsAsBlobs: true)) + { + CreateTable(); + } + } + + [Test] + public void ShouldPersistAndReadGuid() + { + var db = new TestDb(TestPath.GetTempFileName()); + + var obj1 = new TestObj() { Id = new Guid("36473164-C9E4-4CDF-B266-A0B287C85623"), Text = "First Guid Object" }; + var obj2 = new TestObj() { Id = new Guid("BC5C4C4A-CA57-4B61-8B53-9FD4673528B6"), Text = "Second Guid Object" }; + + var numIn1 = db.Insert(obj1); + var numIn2 = db.Insert(obj2); + Assert.AreEqual(1, numIn1); + Assert.AreEqual(1, numIn2); + + var result = db.Query("select * from TestObj").ToList(); + Assert.AreEqual(2, result.Count); + Assert.AreEqual(obj1.Text, result[0].Text); + Assert.AreEqual(obj2.Text, result[1].Text); + + Assert.AreEqual(obj1.Id, result[0].Id); + Assert.AreEqual(obj2.Id, result[1].Id); + + db.Close(); + } + [Test] + public void ShouldQueryGuidCorrectly() + { + var db = new TestDb(TestPath.GetTempFileName()); + + var obj1 = new TestObj() { Id = new Guid("36473164-C9E4-4CDF-B266-A0B287C85623"), Text = "First Guid Object" }; + var obj2 = new TestObj() { Id = new Guid("BC5C4C4A-CA57-4B61-8B53-9FD4673528B6"), Text = "Second Guid Object" }; + + var numIn1 = db.Insert(obj1); + var numIn2 = db.Insert(obj2); + Assert.AreEqual(1, numIn1); + Assert.AreEqual(1, numIn2); + + var result = db.Query("select * from TestObj where id = ?", obj2.Id).ToList(); + Assert.AreEqual(1, result.Count); + Assert.AreEqual(obj2.Text, result[0].Text); + + Assert.AreEqual(obj2.Id, result[0].Id); + + db.Close(); + } + + [Test] + public void ShouldQueryGuidCorrectlyUsingLinq() + { + var db = new TestDb(TestPath.GetTempFileName()); + + var obj1 = new TestObj() { Id = new Guid("36473164-C9E4-4CDF-B266-A0B287C85623"), Text = "First Guid Object" }; + var obj2 = new TestObj() { Id = new Guid("BC5C4C4A-CA57-4B61-8B53-9FD4673528B6"), Text = "Second Guid Object" }; + + var numIn1 = db.Insert(obj1); + var numIn2 = db.Insert(obj2); + Assert.AreEqual(1, numIn1); + Assert.AreEqual(1, numIn2); + + var result = db.Table().Where(to => to.Id == obj2.Id).ToList(); + Assert.AreEqual(1, result.Count); + Assert.AreEqual(obj2.Text, result[0].Text); + + Assert.AreEqual(obj2.Id, result[0].Id); + + db.Close(); + } + + [Test] + public async Task ShouldQueryGuidCorrectlyAsync() + { + + var db = new SQLiteAsyncConnection(TestPath.GetTempFileName(), storeGuidsAsBlobs: true); + await db.CreateTableAsync(CreateFlags.AutoIncPK); + + var obj1 = new TestObj() { Id = new Guid("36473164-C9E4-4CDF-B266-A0B287C85623"), Text = "First Guid Object" }; + var obj2 = new TestObj() { Id = new Guid("BC5C4C4A-CA57-4B61-8B53-9FD4673528B6"), Text = "Second Guid Object" }; + + var numIn1 = await db.InsertAsync(obj1); + var numIn2 = await db.InsertAsync(obj2); + Assert.AreEqual(1, numIn1); + Assert.AreEqual(1, numIn2); + + var result = (await db.QueryAsync("select * from TestObj where id = ?", obj2.Id)).ToList(); + Assert.AreEqual(1, result.Count); + Assert.AreEqual(obj2.Text, result[0].Text); + + Assert.AreEqual(obj2.Id, result[0].Id); + + await db.CloseAsync(); + } + + [Test] + public async Task ShouldQueryGuidCorrectlyUsingLinqAsync() + { + + var db = new SQLiteAsyncConnection(TestPath.GetTempFileName(), storeGuidsAsBlobs: true); + await db.CreateTableAsync(CreateFlags.AutoIncPK); + + var obj1 = new TestObj() { Id = new Guid("36473164-C9E4-4CDF-B266-A0B287C85623"), Text = "First Guid Object" }; + var obj2 = new TestObj() { Id = new Guid("BC5C4C4A-CA57-4B61-8B53-9FD4673528B6"), Text = "Second Guid Object" }; + + var numIn1 = await db.InsertAsync(obj1); + var numIn2 = await db.InsertAsync(obj2); + Assert.AreEqual(1, numIn1); + Assert.AreEqual(1, numIn2); + + var result = await db.Table().Where(to => to.Id == obj2.Id).ToListAsync(); + Assert.AreEqual(1, result.Count); + Assert.AreEqual(obj2.Text, result[0].Text); + + Assert.AreEqual(obj2.Id, result[0].Id); + + await db.CloseAsync(); + } + + + [Test] + public void AutoGuid_HasGuid() + { + var db = new SQLiteConnection(new SQLiteConnectionString (TestPath.GetTempFileName(), storeGuidsAsBlobs: true)); + db.CreateTable(CreateFlags.AutoIncPK); + + var guid1 = new Guid("36473164-C9E4-4CDF-B266-A0B287C85623"); + var guid2 = new Guid("BC5C4C4A-CA57-4B61-8B53-9FD4673528B6"); + + var obj1 = new TestObj() { Id = guid1, Text = "First Guid Object" }; + var obj2 = new TestObj() { Id = guid2, Text = "Second Guid Object" }; + + var numIn1 = db.Insert(obj1); + var numIn2 = db.Insert(obj2); + Assert.AreEqual(guid1, obj1.Id); + Assert.AreEqual(guid2, obj2.Id); + + db.Close(); + } + + [Test] + public void AutoGuid_EmptyGuid() + { + var db = new SQLiteConnection(new SQLiteConnectionString (TestPath.GetTempFileName(), storeGuidsAsBlobs: true)); + db.CreateTable(CreateFlags.AutoIncPK); + + var guid1 = new Guid("36473164-C9E4-4CDF-B266-A0B287C85623"); + var guid2 = new Guid("BC5C4C4A-CA57-4B61-8B53-9FD4673528B6"); + + var obj1 = new TestObj() { Text = "First Guid Object" }; + var obj2 = new TestObj() { Text = "Second Guid Object" }; + + Assert.AreEqual(Guid.Empty, obj1.Id); + Assert.AreEqual(Guid.Empty, obj2.Id); + + var numIn1 = db.Insert(obj1); + var numIn2 = db.Insert(obj2); + Assert.AreNotEqual(Guid.Empty, obj1.Id); + Assert.AreNotEqual(Guid.Empty, obj2.Id); + Assert.AreNotEqual(obj1.Id, obj2.Id); + + db.Close(); + } + } +} diff --git a/tests/IgnoreTest.cs b/tests/SQLite.Tests/IgnoreTest.cs similarity index 100% rename from tests/IgnoreTest.cs rename to tests/SQLite.Tests/IgnoreTest.cs diff --git a/tests/InheritanceTest.cs b/tests/SQLite.Tests/InheritanceTest.cs similarity index 100% rename from tests/InheritanceTest.cs rename to tests/SQLite.Tests/InheritanceTest.cs diff --git a/tests/InsertTest.cs b/tests/SQLite.Tests/InsertTest.cs similarity index 100% rename from tests/InsertTest.cs rename to tests/SQLite.Tests/InsertTest.cs diff --git a/tests/JoinTest.cs b/tests/SQLite.Tests/JoinTest.cs similarity index 100% rename from tests/JoinTest.cs rename to tests/SQLite.Tests/JoinTest.cs diff --git a/tests/LinqTest.cs b/tests/SQLite.Tests/LinqTest.cs similarity index 100% rename from tests/LinqTest.cs rename to tests/SQLite.Tests/LinqTest.cs diff --git a/tests/MappingTest.cs b/tests/SQLite.Tests/MappingTest.cs similarity index 100% rename from tests/MappingTest.cs rename to tests/SQLite.Tests/MappingTest.cs diff --git a/tests/MigrationTest.cs b/tests/SQLite.Tests/MigrationTest.cs similarity index 100% rename from tests/MigrationTest.cs rename to tests/SQLite.Tests/MigrationTest.cs diff --git a/tests/NotNullAttributeTest.cs b/tests/SQLite.Tests/NotNullAttributeTest.cs similarity index 100% rename from tests/NotNullAttributeTest.cs rename to tests/SQLite.Tests/NotNullAttributeTest.cs diff --git a/tests/NullableTest.cs b/tests/SQLite.Tests/NullableTest.cs similarity index 100% rename from tests/NullableTest.cs rename to tests/SQLite.Tests/NullableTest.cs diff --git a/tests/OpenTests.cs b/tests/SQLite.Tests/OpenTests.cs similarity index 100% rename from tests/OpenTests.cs rename to tests/SQLite.Tests/OpenTests.cs diff --git a/tests/QueryTest.cs b/tests/SQLite.Tests/QueryTest.cs similarity index 100% rename from tests/QueryTest.cs rename to tests/SQLite.Tests/QueryTest.cs diff --git a/tests/ReadmeTest.cs b/tests/SQLite.Tests/ReadmeTest.cs similarity index 100% rename from tests/ReadmeTest.cs rename to tests/SQLite.Tests/ReadmeTest.cs diff --git a/tests/SQLCipherTest.cs b/tests/SQLite.Tests/SQLCipherTest.cs similarity index 100% rename from tests/SQLCipherTest.cs rename to tests/SQLite.Tests/SQLCipherTest.cs diff --git a/tests/SQLite.Tests/SQLite.Tests.csproj b/tests/SQLite.Tests/SQLite.Tests.csproj new file mode 100644 index 00000000..b828f939 --- /dev/null +++ b/tests/SQLite.Tests/SQLite.Tests.csproj @@ -0,0 +1,59 @@ + + + + Library + net462 + Debug;Release + latest + AnyCPU;x86 + + + + TRACE;NO_VB + + + + TRACE;NO_VB + + + + + 3.12.0 + + + 3.10.0 + + + 3.10.0 + + + 3.6.0 + + + 3.7.0 + + + 3.6.0 + + + 1.0.6 + + + 3.8.0 + + + + + + SQLite.cs + + + SQLiteAsync.cs + + + + + + + + \ No newline at end of file diff --git a/tests/ScalarTest.cs b/tests/SQLite.Tests/ScalarTest.cs similarity index 100% rename from tests/ScalarTest.cs rename to tests/SQLite.Tests/ScalarTest.cs diff --git a/tests/SkipTest.cs b/tests/SQLite.Tests/SkipTest.cs similarity index 100% rename from tests/SkipTest.cs rename to tests/SQLite.Tests/SkipTest.cs diff --git a/tests/StringQueryTest.cs b/tests/SQLite.Tests/StringQueryTest.cs similarity index 99% rename from tests/StringQueryTest.cs rename to tests/SQLite.Tests/StringQueryTest.cs index ae474b91..c71a7792 100644 --- a/tests/StringQueryTest.cs +++ b/tests/SQLite.Tests/StringQueryTest.cs @@ -34,29 +34,29 @@ public void SetUp () } [Test] - public void StringEquals () - { - // C#: x => x.Name == "Foo" - var fs = db.Table().Where(x => x.Name == "Foo").ToList(); - Assert.AreEqual(1, fs.Count); + public void StringEquals () + { + // C#: x => x.Name == "Foo" + var fs = db.Table().Where(x => x.Name == "Foo").ToList(); + Assert.AreEqual(1, fs.Count); -#if !NO_VB - // VB: Function(x) x.Name = "Foo" - var param = System.Linq.Expressions.Expression.Parameter(typeof(Product), "x"); - var expr = System.Linq.Expressions.Expression.Lambda>( - System.Linq.Expressions.Expression.Equal( - System.Linq.Expressions.Expression.Call( - typeof(Microsoft.VisualBasic.CompilerServices.Operators).GetMethod("CompareString"), - System.Linq.Expressions.Expression.MakeMemberAccess(param, typeof(Product).GetMember("Name").First()), - System.Linq.Expressions.Expression.Constant("Foo"), - System.Linq.Expressions.Expression.Constant(false)), // Option Compare Binary (false) or Text (true) - System.Linq.Expressions.Expression.Constant(0)), - param); - var bs = db.Table().Where(expr).ToList(); +#if !NO_VB + // VB: Function(x) x.Name = "Foo" + var param = System.Linq.Expressions.Expression.Parameter(typeof(Product), "x"); + var expr = System.Linq.Expressions.Expression.Lambda>( + System.Linq.Expressions.Expression.Equal( + System.Linq.Expressions.Expression.Call( + typeof(Microsoft.VisualBasic.CompilerServices.Operators).GetMethod("CompareString"), + System.Linq.Expressions.Expression.MakeMemberAccess(param, typeof(Product).GetMember("Name").First()), + System.Linq.Expressions.Expression.Constant("Foo"), + System.Linq.Expressions.Expression.Constant(false)), // Option Compare Binary (false) or Text (true) + System.Linq.Expressions.Expression.Constant(0)), + param); + var bs = db.Table().Where(expr).ToList(); Assert.AreEqual(1, bs.Count); -#endif - } - +#endif + } + [Test] public void StartsWith () { @@ -68,9 +68,9 @@ public void StartsWith () var lfs2 = db.Table().Where(x => x.Name.StartsWith("f",StringComparison.OrdinalIgnoreCase)).ToList(); - Assert.AreEqual(2, lfs2.Count); - - + Assert.AreEqual(2, lfs2.Count); + + var bs = db.Table ().Where (x => x.Name.StartsWith ("B")).ToList (); Assert.AreEqual (1, bs.Count); } @@ -83,7 +83,7 @@ public void EndsWith () var lfs = db.Table().Where(x => x.Name.EndsWith("Ar")).ToList(); Assert.AreEqual(0, lfs.Count); - + var bs = db.Table ().Where (x => x.Name.EndsWith ("o")).ToList (); Assert.AreEqual (1, bs.Count); } @@ -93,18 +93,18 @@ public void Contains () { var fs = db.Table().Where(x => x.Name.Contains("o")).ToList(); Assert.AreEqual(2, fs.Count); - + var lfs = db.Table ().Where (x => x.Name.Contains ("O")).ToList (); Assert.AreEqual (0, lfs.Count); var lfsu = db.Table().Where(x => x.Name.ToUpper().Contains("O")).ToList(); - Assert.AreEqual(2, lfsu.Count); - + Assert.AreEqual(2, lfsu.Count); + var bs = db.Table ().Where (x => x.Name.Contains ("a")).ToList (); Assert.AreEqual (2, bs.Count); var zs = db.Table().Where(x => x.Name.Contains("z")).ToList(); - Assert.AreEqual(0, zs.Count); + Assert.AreEqual(0, zs.Count); } } } diff --git a/tests/TableChangedTest.cs b/tests/SQLite.Tests/TableChangedTest.cs similarity index 100% rename from tests/TableChangedTest.cs rename to tests/SQLite.Tests/TableChangedTest.cs diff --git a/tests/TestDb.cs b/tests/SQLite.Tests/TestDb.cs similarity index 100% rename from tests/TestDb.cs rename to tests/SQLite.Tests/TestDb.cs diff --git a/tests/TimeSpanTest.cs b/tests/SQLite.Tests/TimeSpanTest.cs similarity index 100% rename from tests/TimeSpanTest.cs rename to tests/SQLite.Tests/TimeSpanTest.cs diff --git a/tests/TransactionTest.cs b/tests/SQLite.Tests/TransactionTest.cs similarity index 100% rename from tests/TransactionTest.cs rename to tests/SQLite.Tests/TransactionTest.cs diff --git a/tests/UnicodeTest.cs b/tests/SQLite.Tests/UnicodeTest.cs similarity index 100% rename from tests/UnicodeTest.cs rename to tests/SQLite.Tests/UnicodeTest.cs diff --git a/tests/UniqueTest.cs b/tests/SQLite.Tests/UniqueTest.cs similarity index 100% rename from tests/UniqueTest.cs rename to tests/SQLite.Tests/UniqueTest.cs diff --git a/tests/packages.config b/tests/packages.config deleted file mode 100644 index 9c8b0dc6..00000000 --- a/tests/packages.config +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file