Skip to content

Commit

Permalink
Merge pull request #158 from mk3008/157-parse-of-type-conversion-usin…
Browse files Browse the repository at this point in the history
…g-bracket-does-not-work

Supports type conversion parsing using Bracket
  • Loading branch information
mk3008 authored Nov 16, 2022
2 parents f6901e1 + b324c4c commit 3990de5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/SqModel/Analysis/ValueClauseParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ private static IValueClause ParseCore(SqlParser parser)

q.First();

if (parser.CurrentToken.ToLower() == "over")
if (parser.CurrentToken.ToLower() == "over" || parser.CurrentToken == "(")
{
return recursiveParse();
}
Expand Down Expand Up @@ -163,7 +163,7 @@ private static CommandValue ToCommandValue(List<string> cache)
{
sb.Append(x);
}
else if (x == "." || x == "(" || x == ")" || x.StartsWith("::"))
else if (x == "." || x.StartsWith("(") || x == ")" || x.StartsWith("::"))
{
sb.Append(x);
}
Expand Down
2 changes: 1 addition & 1 deletion src/SqModel/SqModel.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<PackageProjectUrl>https://github.com/mk3008/SqModel</PackageProjectUrl>
<AssemblyVersion></AssemblyVersion>
<FileVersion></FileVersion>
<Version>0.8.5</Version>
<Version>0.8.6</Version>
<PackageTags>Sql;QueryBuilder;SqlParser;ORM;</PackageTags>
<PackageReadmeFile>README.md</PackageReadmeFile>
<Description>Parse and build select queries.</Description>
Expand Down
11 changes: 11 additions & 0 deletions test/SqModelTest/AnalysisTest/ParseTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,17 @@ public void CaseElseTest()
Assert.Equal(expect, text);
}

[Fact]
public void TypeConvertWithBracket()
{
var sq = SqlParser.Parse("select 3.1415::numeric(8,2) as val1");
var text = sq.ToQuery().CommandText;
var expect = @"select
3.1415::numeric(8,2) as val1";
Assert.Equal(expect, text);
}


[Fact]
public void Full()
{
Expand Down

0 comments on commit 3990de5

Please sign in to comment.