Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/Microsoft.Data.Sqlite.Core/SqliteParameterBinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ namespace Microsoft.Data.Sqlite;
internal class SqliteParameterBinder(sqlite3_stmt stmt, sqlite3 handle, int index, object value, int? size, SqliteType? sqliteType)
: SqliteValueBinder(value, sqliteType)
{
protected override void BindBlob(byte[] value)
protected override void BindBlob(ReadOnlySpan<byte> value)
{
var blob = value;
if (ShouldTruncate(value.Length))
{
blob = new byte[size!.Value];
Array.Copy(value, blob, size.Value);
blob = value.Slice(0, size!.Value);
}

var rc = sqlite3_bind_blob(stmt, index, blob);

SqliteException.ThrowExceptionForRC(rc, handle);
}

Expand Down
3 changes: 2 additions & 1 deletion src/Microsoft.Data.Sqlite.Core/SqliteResultBinder.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using SQLitePCL;
using static SQLitePCL.raw;

namespace Microsoft.Data.Sqlite;

internal class SqliteResultBinder(sqlite3_context ctx, object? value) : SqliteValueBinder(value)
{
protected override void BindBlob(byte[] value)
protected override void BindBlob(ReadOnlySpan<byte> value)
=> sqlite3_result_blob(ctx, value);

protected override void BindDoubleCore(double value)
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.Data.Sqlite.Core/SqliteValueBinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ protected virtual void BindDouble(double value)

protected abstract void BindText(string value);

protected abstract void BindBlob(byte[] value);
protected abstract void BindBlob(ReadOnlySpan<byte> value);

protected abstract void BindNull();

Expand Down