Skip to content

Commit

Permalink
fix #213
Browse files Browse the repository at this point in the history
  • Loading branch information
Ahoo-Wang committed May 13, 2022
1 parent 5e31dbf commit 4dbe23a
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 2 deletions.
2 changes: 1 addition & 1 deletion build/version.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<VersionMajor>4</VersionMajor>
<VersionMinor>1</VersionMinor>
<VersionPatch>63</VersionPatch>
<VersionPatch>64</VersionPatch>
<VersionPrefix>$(VersionMajor).$(VersionMinor).$(VersionPatch)</VersionPrefix>
</PropertyGroup>
</Project>
52 changes: 52 additions & 0 deletions src/SmartSql.Test.Unit/Tags/SqlTextTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
using SmartSql.Configuration.Tags;
using Xunit;

namespace SmartSql.Test.Unit.Tags;

public class SqlTextTest
{
[Fact]
public void BuildSql()
{
var expected = "id=?id";
SqlText sqlText = new SqlText(expected, "?");
RequestContext requestContext = new RequestContext();
sqlText.BuildSql(requestContext);
var actual = requestContext.SqlBuilder.ToString();
Assert.Equal(expected, actual);
}

[Fact]
public void BuildSqlWithIn()
{
SqlText sqlText = new SqlText("in ?Ids", "?");
RequestContext requestContext = new RequestContext()
{
Request = new
{
Ids = new[] { 1, 2 }
}
};
requestContext.SetupParameters();
sqlText.BuildSql(requestContext);
var actual = requestContext.SqlBuilder.ToString();
Assert.Equal("In (?Ids_0,?Ids_1)", actual);
}

[Fact]
public void BuildSqlWithInAndSemicolon()
{
SqlText sqlText = new SqlText("in ?Ids;", "?");
RequestContext requestContext = new RequestContext()
{
Request = new
{
Ids = new[] { 1, 2 }
}
};
requestContext.SetupParameters();
sqlText.BuildSql(requestContext);
var actual = requestContext.SqlBuilder.ToString();
Assert.Equal("In (?Ids_0,?Ids_1);", actual);
}
}
2 changes: 1 addition & 1 deletion src/SmartSql/Configuration/Tags/SqlText.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public SqlText(string bodyText, string dbPrefix)
{
BodyText = bodyText;
_dbPrefix = dbPrefix;
_sqlInParamsTokens = new Regex(@"in\s*[" + dbPrefix + @"]([\S_.]+)", RegexOptions.IgnoreCase);
_sqlInParamsTokens = new Regex(@"in\s*[" + dbPrefix + @"]([\p{L}\p{N}_.]+)", RegexOptions.IgnoreCase);
_hasInSyntax = _sqlInParamsTokens.IsMatch(bodyText);
}

Expand Down

0 comments on commit 4dbe23a

Please sign in to comment.