Skip to content

Commit

Permalink
Updated SQLite binaries.
Browse files Browse the repository at this point in the history
  • Loading branch information
smourier committed May 23, 2019
1 parent a3430c9 commit bc36d27
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 25 deletions.
55 changes: 37 additions & 18 deletions Amalgamation/SqlNado.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5820,20 +5820,20 @@ public virtual string GetDefaultDataType(Type type)
type == typeof(short) || type == typeof(sbyte) || type == typeof(byte) ||
type == typeof(uint) || type == typeof(ushort) || type == typeof(ulong) ||
type.IsEnum || type == typeof(bool))
return SQLiteColumnType.INTEGER.ToString();
return nameof(SQLiteColumnType.INTEGER);

if (type == typeof(float) || type == typeof(double))
return SQLiteColumnType.REAL.ToString();
return nameof(SQLiteColumnType.REAL);

if (type == typeof(byte[]))
return SQLiteColumnType.BLOB.ToString();
return nameof(SQLiteColumnType.BLOB);

if (type == typeof(decimal))
{
if (Database.BindOptions.DecimalAsBlob)
return SQLiteColumnType.BLOB.ToString();
return nameof(SQLiteColumnType.BLOB);

return SQLiteColumnType.TEXT.ToString();
return nameof(SQLiteColumnType.TEXT);
}

if (type == typeof(DateTime) || type == typeof(DateTimeOffset))
Expand All @@ -5843,32 +5843,32 @@ public virtual string GetDefaultDataType(Type type)
Database.BindOptions.DateTimeFormat == SQLiteDateTimeFormat.FileTimeUtc ||
Database.BindOptions.DateTimeFormat == SQLiteDateTimeFormat.UnixTimeSeconds ||
Database.BindOptions.DateTimeFormat == SQLiteDateTimeFormat.UnixTimeMilliseconds)
return SQLiteColumnType.INTEGER.ToString();
return nameof(SQLiteColumnType.INTEGER);

if (Database.BindOptions.DateTimeFormat == SQLiteDateTimeFormat.OleAutomation ||
Database.BindOptions.DateTimeFormat == SQLiteDateTimeFormat.JulianDayNumbers)
return SQLiteColumnType.INTEGER.ToString();
return nameof(SQLiteColumnType.INTEGER);

return SQLiteColumnType.TEXT.ToString();
return nameof(SQLiteColumnType.TEXT);
}

if (type == typeof(Guid))
{
if (Database.BindOptions.GuidAsBlob)
return SQLiteColumnType.BLOB.ToString();
return nameof(SQLiteColumnType.BLOB);

return SQLiteColumnType.TEXT.ToString();
return nameof(SQLiteColumnType.TEXT);
}

if (type == typeof(TimeSpan))
{
if (Database.BindOptions.TimeSpanAsInt64)
return SQLiteColumnType.INTEGER.ToString();
return nameof(SQLiteColumnType.INTEGER);

return SQLiteColumnType.TEXT.ToString();
return nameof(SQLiteColumnType.TEXT);
}

return SQLiteColumnType.TEXT.ToString();
return nameof(SQLiteColumnType.TEXT);
}

internal static bool IsComputedDefaultValue(string value) =>
Expand Down Expand Up @@ -5923,7 +5923,7 @@ protected virtual SQLiteColumnAttribute GetColumnAttribute(PropertyInfo property
{
if (typeof(ISQLiteBlobObject).IsAssignableFrom(att.ClrType))
{
att.DataType = SQLiteColumnType.BLOB.ToString();
att.DataType = nameof(SQLiteColumnType.BLOB);
}
else
{
Expand All @@ -5932,7 +5932,7 @@ protected virtual SQLiteColumnAttribute GetColumnAttribute(PropertyInfo property
// https://www.sqlite.org/lang_createtable.html
if (IsComputedDefaultValue(df))
{
att.DataType = SQLiteColumnType.TEXT.ToString();
att.DataType = nameof(SQLiteColumnType.TEXT);
// we need to force this column type options
att.BindOptions = att.BindOptions ?? Database.CreateBindOptions();
att.BindOptions.DateTimeFormat = SQLiteDateTimeFormat.SQLiteIso8601;
Expand All @@ -5942,7 +5942,15 @@ protected virtual SQLiteColumnAttribute GetColumnAttribute(PropertyInfo property

if (string.IsNullOrWhiteSpace(att.DataType))
{
att.DataType = GetDefaultDataType(att.ClrType);
var nta = att.ClrType.GetNullableTypeArgument();
if (nta != null)
{
att.DataType = GetDefaultDataType(nta);
}
else
{
att.DataType = GetDefaultDataType(att.ClrType);
}
}
}

Expand Down Expand Up @@ -7741,7 +7749,7 @@ public IReadOnlyList<SQLiteColumn> HiddenColumns

foreach (var column in Columns)
{
var existing = all.FirstOrDefault(c => string.Equals(c.Name, column.Name, StringComparison.Ordinal));
var existing = all.Find(c => string.Equals(c.Name, column.Name, StringComparison.Ordinal));
if (existing != null)
{
all.Remove(existing);
Expand Down Expand Up @@ -7797,7 +7805,7 @@ private bool CanBeRowId(SQLiteColumn column)
if (!column.IsPrimaryKey)
return false;

if (!column.Type.EqualsIgnoreCase(SQLiteColumnType.INTEGER.ToString()))
if (!column.Type.EqualsIgnoreCase(nameof(SQLiteColumnType.INTEGER)))
return false;

// https://sqlite.org/lang_createtable.html#rowid
Expand Down Expand Up @@ -8606,6 +8614,17 @@ public static string Nullify(this string text)
return t.Length == 0 ? null : t;
}

public static Type GetNullableTypeArgument(this Type type)
{
if (type == null)
throw new ArgumentNullException(nameof(type));

if (!IsNullable(type))
return null;

return type.GetGenericArguments()[0];
}

public static bool IsNullable(this Type type)
{
if (type == null)
Expand Down
2 changes: 1 addition & 1 deletion SqlNado.Converter/SqlNado.Converter.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="DatabaseSchemaReader">
<Version>2.6.3</Version>
<Version>2.7.1</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions SqlNado.Tests/SqlNado.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
<PackageReference Include="MSTest.TestAdapter" Version="1.3.2" />
<PackageReference Include="MSTest.TestFramework" Version="1.3.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.1.0" />
<PackageReference Include="MSTest.TestAdapter" Version="1.4.0" />
<PackageReference Include="MSTest.TestFramework" Version="1.4.0" />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions SqlNado/SqlNado.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<Version>1.2.1</Version>
<AssemblyVersion>1.2.1.0</AssemblyVersion>
<FileVersion>1.2.1.0</FileVersion>
<Version>1.2.2</Version>
<AssemblyVersion>1.2.2.0</AssemblyVersion>
<FileVersion>1.2.2.0</FileVersion>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Authors>Simon Mourier</Authors>
<Copyright>Copyright (c) 2017-2019 Simon Mourier. All rights reserved.</Copyright>
Expand Down
Binary file modified SqlNado/sqlite3.x64.dll
Binary file not shown.
Binary file modified SqlNado/sqlite3.x86.dll
Binary file not shown.

0 comments on commit bc36d27

Please sign in to comment.