Skip to content

Commit f4cafcf

Browse files
committed
v2.0.0
1 parent 5f13448 commit f4cafcf

11 files changed

Lines changed: 32 additions & 34 deletions

File tree

SQLite.Net.Tests/ByteArrayTest.cs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -135,25 +135,23 @@ public void ByteArrayWhere()
135135
[Description("Uses a null byte array to find a record")]
136136
public void ByteArrayWhereNull()
137137
{
138-
//Byte Arrays for comparisson
139-
ByteArrayClass[] byteArrays = new ByteArrayClass[] {
140-
new ByteArrayClass() { bytes = new byte[] { 1, 2, 3, 4, 250, 252, 253, 254, 255 } }, //Range check
141-
new ByteArrayClass() { bytes = new byte[] { 0 } }, //null bytes need to be handled correctly
142-
new ByteArrayClass() { bytes = new byte[] { 0, 0 } },
143-
new ByteArrayClass() { bytes = new byte[] { 0, 1, 0 } },
144-
new ByteArrayClass() { bytes = new byte[] { 1, 0, 1 } },
145-
new ByteArrayClass() { bytes = new byte[] { } }, //Empty byte array should stay empty (and not become null)
146-
new ByteArrayClass() { bytes = null } //Null should be supported
138+
//Byte Arrays for comparison
139+
ByteArrayClass[] byteArrays = {
140+
new ByteArrayClass { bytes = new byte[] { 1, 2, 3, 4, 250, 252, 253, 254, 255 } }, //Range check
141+
new ByteArrayClass { bytes = new byte[] { 0 } }, //null bytes need to be handled correctly
142+
new ByteArrayClass { bytes = new byte[] { } }, //Empty byte array should stay empty (and not become null)
143+
new ByteArrayClass { bytes = new byte[] { 0, 0 } },
144+
new ByteArrayClass { bytes = new byte[] { 0, 1, 0 } },
145+
new ByteArrayClass { bytes = new byte[] { 1, 0, 1 } },
146+
new ByteArrayClass { bytes = null } //Null should be supported
147147
};
148148

149149
var database = new SQLiteConnection(TestPath.CreateTemporaryDatabase());
150150
database.CreateTable<ByteArrayClass>();
151151

152-
byte[] criterion = null;
153-
154152
//Insert all of the ByteArrayClass
155153
int id = 0;
156-
foreach (ByteArrayClass b in byteArrays)
154+
foreach (var b in byteArrays)
157155
{
158156
database.Insert(b);
159157
if (b.bytes == null)
@@ -162,7 +160,7 @@ public void ByteArrayWhereNull()
162160
Assert.AreNotEqual(0, id, "An ID wasn't set");
163161

164162
//Get it back out
165-
ByteArrayClass fetchedByteArray = database.Table<ByteArrayClass>().Where(x => x.bytes == criterion).First();
163+
var fetchedByteArray = database.Table<ByteArrayClass>().FirstOrDefault(x => x.bytes == null);
166164

167165
Assert.IsNotNull(fetchedByteArray);
168166
//Check they are the same

SQLite.Net.Tests/SQLite.Net2.Tests.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="nunit" Version="3.11.0" />
11-
<PackageReference Include="NUnit3TestAdapter" Version="3.13.0" />
12-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.0.1" />
10+
<PackageReference Include="nunit" Version="3.12.0" />
11+
<PackageReference Include="NUnit3TestAdapter" Version="3.14.0" />
12+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
1313
</ItemGroup>
1414

1515
<ItemGroup>

examples/Stocks/Stocks.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
</ItemGroup>
8181
<ItemGroup>
8282
<PackageReference Include="SQLitePCLRaw.bundle_e_sqlite3">
83-
<Version>1.1.13</Version>
83+
<Version>2.0.0</Version>
8484
</PackageReference>
8585
</ItemGroup>
8686
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />

nuget/pack.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ cd nuget
1818

1919
del *.nupkg
2020

21-
$version="1.0.0"
21+
$version="2.0.0"
2222
nuget pack "sqlite-net2.nuspec" -Version $version
2323
nuget push "sqlite-net2.$version.nupkg" -Source $nugetServer
2424

nuget/sqlite-net2.nuspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
33
<metadata minClientVersion="2.5">
44
<id>sqlite-net2</id>
5-
<version>1.0.0</version>
5+
<version>2.0.0</version>
66
<title>sqlite-net2</title>
77
<authors>Benjamin Mayrargue</authors>
88
<owners>Benjamin Mayrargue</owners>
@@ -20,7 +20,7 @@
2020
<summary>A .NET client library to access SQLite embedded database files in a LINQ manner.</summary>
2121

2222
<dependencies>
23-
<dependency id="SQLitePCLRaw.bundle_e_sqlite3" version="1.1.13" />
23+
<dependency id="SQLitePCLRaw.bundle_e_sqlite3" version="2.0.0" />
2424
</dependencies>
2525

2626
</metadata>

src/SQLite.Net/Interfaces/IBlobSerializer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public interface IBlobSerializer
3636
/// <param name="data">Serialized object</param>
3737
/// <param name="type">Type of object</param>
3838
/// <returns>Deserialized object</returns>
39-
object Deserialize(byte[] data, Type type);
39+
object Deserialize(ReadOnlySpan<byte> data, Type type);
4040

4141
bool CanDeserialize(Type type);
4242
}

src/SQLite.Net/Interfaces/ISQLiteApi.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ public interface ISQLiteApi
7272
// string ColumnText(IDbStatement stmt, int index);
7373

7474
string ColumnText16(IDbStatement stmt, int index);
75-
byte[] ColumnBlob(IDbStatement stmt, int index);
75+
ReadOnlySpan<byte> ColumnBlob(IDbStatement stmt, int index);
7676
int ColumnBytes(IDbStatement stmt, int index);
7777
// string ColumnText(IDbStatement stmt, int index);
7878

79-
byte[] ColumnByteArray(IDbStatement stmt, int index);
79+
ReadOnlySpan<byte> ColumnByteArray(IDbStatement stmt, int index);
8080

8181

8282
#region Backup

src/SQLite.Net/Interop/SQLiteApi.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public int Threadsafe()
3232

3333
public string SourceID()
3434
{
35-
return raw.sqlite3_sourceid();
35+
return raw.sqlite3_sourceid().utf8_to_string();
3636
}
3737

3838
public Result EnableLoadExtension(IDbHandle db, int onoff)
@@ -117,7 +117,7 @@ public long LastInsertRowid(IDbHandle db)
117117
public string Errmsg16(IDbHandle db)
118118
{
119119
var internalDbHandle = (DbHandle)db;
120-
return raw.sqlite3_errmsg(internalDbHandle.DbPtr);
120+
return raw.sqlite3_errmsg(internalDbHandle.DbPtr).utf8_to_string();
121121
}
122122

123123
public int BindParameterIndex(IDbStatement stmt, string name)
@@ -171,7 +171,7 @@ public int ColumnCount(IDbStatement stmt)
171171
public string ColumnName16(IDbStatement stmt, int index)
172172
{
173173
var internalStmt = (DbStatement)stmt;
174-
return raw.sqlite3_column_name(internalStmt.StmtPtr, index);
174+
return raw.sqlite3_column_name(internalStmt.StmtPtr, index).utf8_to_string();
175175
}
176176

177177
public ColType ColumnType(IDbStatement stmt, int index)
@@ -201,10 +201,10 @@ public double ColumnDouble(IDbStatement stmt, int index)
201201
public string ColumnText16(IDbStatement stmt, int index)
202202
{
203203
var internalStmt = (DbStatement)stmt;
204-
return raw.sqlite3_column_text(internalStmt.StmtPtr, index);
204+
return raw.sqlite3_column_text(internalStmt.StmtPtr, index).utf8_to_string();
205205
}
206206

207-
public byte[] ColumnBlob(IDbStatement stmt, int index)
207+
public ReadOnlySpan<byte> ColumnBlob(IDbStatement stmt, int index)
208208
{
209209
var internalStmt = (DbStatement)stmt;
210210
return raw.sqlite3_column_blob(internalStmt.StmtPtr, index);
@@ -216,7 +216,7 @@ public int ColumnBytes(IDbStatement stmt, int index)
216216
return raw.sqlite3_column_bytes(internalStmt.StmtPtr, index);
217217
}
218218

219-
public byte[] ColumnByteArray(IDbStatement stmt, int index)
219+
public ReadOnlySpan<byte> ColumnByteArray(IDbStatement stmt, int index)
220220
{
221221
var internalStmt = (DbStatement)stmt;
222222
return raw.sqlite3_column_blob(internalStmt.StmtPtr, index);

src/SQLite.Net/SQLite.Net2.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
</ItemGroup>
1212

1313
<ItemGroup>
14-
<PackageReference Include="SQLitePCLRaw.bundle_e_sqlite3" Version="1.1.13" />
14+
<PackageReference Include="SQLitePCLRaw.bundle_e_sqlite3" Version="2.0.0" />
1515
</ItemGroup>
1616

1717
</Project>

src/SQLite.Net/SQLiteCommand.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -619,12 +619,12 @@ private object ReadCol(IDbStatement stmt, int index, ColType type, Type clrType)
619619
}
620620
if (clrType == typeof (byte[]))
621621
{
622-
return sqlite.ColumnByteArray(stmt, index);
622+
return sqlite.ColumnByteArray(stmt, index).ToArray();
623623
}
624624
if (interfaces.Contains(typeof (ISerializable<byte[]>)))
625625
{
626626
var value = sqlite.ColumnByteArray(stmt, index);
627-
return _conn.Resolver.CreateObject(clrType, new object[] {value});
627+
return _conn.Resolver.CreateObject(clrType, new object[] {value.ToArray()});
628628
}
629629
if (clrType == typeof (Guid))
630630
{

0 commit comments

Comments
 (0)