Skip to content

Commit 74e6265

Browse files
committed
resolve issue-211
update test add condition
1 parent b3e0237 commit 74e6265

2 files changed

Lines changed: 27 additions & 2 deletions

File tree

QueryBuilder.Tests/InsertTests.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Linq;
23
using SqlKata.Compilers;
34
using SqlKata.Tests.Infrastructure;
45
using Xunit;
@@ -113,5 +114,25 @@ public void InsertWithEmptyString()
113114
"INSERT INTO \"BOOKS\" (\"ID\", \"AUTHOR\", \"ISBN\", \"DESCRIPTION\") VALUES (1, 'Author 1', '123456', '')",
114115
c[EngineCodes.Firebird]);
115116
}
117+
118+
[Fact]
119+
public void InsertWithByteArray()
120+
{
121+
var fauxImagebytes = new byte[] {0x1, 0x3, 0x3, 0x7};
122+
var query = new Query("Books")
123+
.AsInsert(new[]{"Id", "CoverImageBytes"},
124+
new object[]
125+
{
126+
1,
127+
fauxImagebytes
128+
});
129+
130+
var c = Compilers.Compile(query);
131+
Assert.All(c.Values, a => Assert.Equal(2, a.NamedBindings.Count));
132+
133+
var exemplar = c[EngineCodes.SqlServer];
134+
Assert.Equal("INSERT INTO [Books] ([Id], [CoverImageBytes]) VALUES (?, ?)", exemplar.RawSql);
135+
Assert.Equal("INSERT INTO [Books] ([Id], [CoverImageBytes]) VALUES (@p0, @p1)", exemplar.Sql);
136+
}
116137
}
117138
}

QueryBuilder/Helper.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using System.Collections;
33
using System.Collections.Generic;
44
using System.Linq;
5-
using System.Reflection;
65
using System.Text.RegularExpressions;
76

87
namespace SqlKata
@@ -11,7 +10,12 @@ public static class Helper
1110
{
1211
public static bool IsArray(object value)
1312
{
14-
if (value is string)
13+
if(value is string)
14+
{
15+
return false;
16+
}
17+
18+
if (value is byte[])
1519
{
1620
return false;
1721
}

0 commit comments

Comments
 (0)