Skip to content

Commit 4dbe23a

Browse files
committed
fix #213
1 parent 5e31dbf commit 4dbe23a

File tree

3 files changed

+54
-2
lines changed

3 files changed

+54
-2
lines changed

build/version.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<PropertyGroup>
33
<VersionMajor>4</VersionMajor>
44
<VersionMinor>1</VersionMinor>
5-
<VersionPatch>63</VersionPatch>
5+
<VersionPatch>64</VersionPatch>
66
<VersionPrefix>$(VersionMajor).$(VersionMinor).$(VersionPatch)</VersionPrefix>
77
</PropertyGroup>
88
</Project>
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
using SmartSql.Configuration.Tags;
2+
using Xunit;
3+
4+
namespace SmartSql.Test.Unit.Tags;
5+
6+
public class SqlTextTest
7+
{
8+
[Fact]
9+
public void BuildSql()
10+
{
11+
var expected = "id=?id";
12+
SqlText sqlText = new SqlText(expected, "?");
13+
RequestContext requestContext = new RequestContext();
14+
sqlText.BuildSql(requestContext);
15+
var actual = requestContext.SqlBuilder.ToString();
16+
Assert.Equal(expected, actual);
17+
}
18+
19+
[Fact]
20+
public void BuildSqlWithIn()
21+
{
22+
SqlText sqlText = new SqlText("in ?Ids", "?");
23+
RequestContext requestContext = new RequestContext()
24+
{
25+
Request = new
26+
{
27+
Ids = new[] { 1, 2 }
28+
}
29+
};
30+
requestContext.SetupParameters();
31+
sqlText.BuildSql(requestContext);
32+
var actual = requestContext.SqlBuilder.ToString();
33+
Assert.Equal("In (?Ids_0,?Ids_1)", actual);
34+
}
35+
36+
[Fact]
37+
public void BuildSqlWithInAndSemicolon()
38+
{
39+
SqlText sqlText = new SqlText("in ?Ids;", "?");
40+
RequestContext requestContext = new RequestContext()
41+
{
42+
Request = new
43+
{
44+
Ids = new[] { 1, 2 }
45+
}
46+
};
47+
requestContext.SetupParameters();
48+
sqlText.BuildSql(requestContext);
49+
var actual = requestContext.SqlBuilder.ToString();
50+
Assert.Equal("In (?Ids_0,?Ids_1);", actual);
51+
}
52+
}

src/SmartSql/Configuration/Tags/SqlText.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public SqlText(string bodyText, string dbPrefix)
1717
{
1818
BodyText = bodyText;
1919
_dbPrefix = dbPrefix;
20-
_sqlInParamsTokens = new Regex(@"in\s*[" + dbPrefix + @"]([\S_.]+)", RegexOptions.IgnoreCase);
20+
_sqlInParamsTokens = new Regex(@"in\s*[" + dbPrefix + @"]([\p{L}\p{N}_.]+)", RegexOptions.IgnoreCase);
2121
_hasInSyntax = _sqlInParamsTokens.IsMatch(bodyText);
2222
}
2323

0 commit comments

Comments
 (0)