├── RestSQL
├── RsqlLexer.g4.cs
├── RsqlParser.g4.cs
├── RsqlQueryType.cs
├── RestSQL.cs
├── RestSQL.csproj
├── IExpressionBuilder.cs
├── RsqlParser.g4
├── RsqlLexer.g4
└── RsqlExpressionVisitor.cs
├── RestSQL.SqlKata
├── IColumnNameTransform.cs
├── RestSQL.SqlKata.csproj
└── SqlKataBuilder.cs
├── .vscode
├── tasks.json
└── launch.json
├── RestSQL.NPoco
├── NPocoExtensions.cs
├── RestSQL.NPoco.csproj
├── NPocoExpression.cs
└── NPocoBuilder.cs
├── .github
├── dependabot.yml
├── ISSUE_TEMPLATE
│ ├── bug_report.md
│ └── feature_request.md
└── workflows
│ └── nuget.yml
├── RestSQL.NPoco.Tests
├── RestSQL.NPoco.Tests.csproj
└── UnitTest1.cs
├── RestSQL.Tests
├── RestSQL.Tests.csproj
├── Providers
│ ├── TestExpression.cs
│ └── TestExpressionBuilder.cs
└── ParseTests.cs
├── RestSQL.SqlKata.Tests
├── RestSQL.SqlKata.Tests.csproj
└── UnitTest1.cs
├── README.md
├── .gitattributes
├── CODE_OF_CONDUCT.md
├── RestSQL.sln
├── .gitignore
└── LICENSE
/RestSQL/RsqlLexer.g4.cs:
--------------------------------------------------------------------------------
1 | namespace RestSQL
2 | {
3 | partial class RsqlLexer
4 | {
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/RestSQL/RsqlParser.g4.cs:
--------------------------------------------------------------------------------
1 | namespace RestSQL
2 | {
3 | partial class RsqlParser
4 | {
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/RestSQL.SqlKata/IColumnNameTransform.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace RestSQL.SqlKata
6 | {
7 | public interface IColumnNameTransform
8 | {
9 | string Transform(string columnName);
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/.vscode/tasks.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0.0",
3 | "tasks": [
4 | {
5 | "label": "build",
6 | "command": "dotnet",
7 | "type": "process",
8 | "args": [
9 | "build",
10 | "${workspaceFolder}/RestSQL.SqlKata.Tests/RestSQL.SqlKata.Tests.csproj"
11 | ],
12 | "problemMatcher": "$msCompile"
13 | }
14 | ]
15 | }
--------------------------------------------------------------------------------
/RestSQL/RsqlQueryType.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace RestSQL
6 | {
7 | public enum RSqlQueryType
8 | {
9 | Between,
10 | Equal,
11 | GreaterOrEqual,
12 | In,
13 | GreatherThan,
14 | IsNotNull,
15 | IsNull,
16 | LessOrEqual,
17 | Like,
18 | LessThan,
19 | NotBetween,
20 | NotEqual,
21 | NotIn,
22 | NotLike
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/RestSQL.NPoco/NPocoExtensions.cs:
--------------------------------------------------------------------------------
1 | using RestSQL.NPoco;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 |
7 | namespace NPoco
8 | {
9 | public static class NPocoExtensions
10 | {
11 | public static SqlBuilder Where(this SqlBuilder sql, string where)
12 | {
13 | var builder = new NPocoBuilder();
14 | var expression = builder.Build(where);
15 | return sql.Where(expression.Sql, expression.Params.ToArray());
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/.github/dependabot.yml:
--------------------------------------------------------------------------------
1 | # To get started with Dependabot version updates, you'll need to specify which
2 | # package ecosystems to update and where the package manifests are located.
3 | # Please see the documentation for all configuration options:
4 | # https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5 |
6 | version: 2
7 | updates:
8 | - package-ecosystem: "nuget" # See documentation for possible values
9 | directory: "/" # Location of package manifests
10 | schedule:
11 | interval: "daily"
12 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve
4 | title: "[BUG] "
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Describe the bug**
11 | A clear and concise description of what the bug is.
12 |
13 | **To Reproduce**
14 | Steps to reproduce the behavior:
15 |
16 | **Expected behavior**
17 | A clear and concise description of what you expected to happen.
18 |
19 | **Actual behavior**
20 | If applicable, add some examples to help explain your problem.
21 |
22 | **Additional context**
23 | Add any other context about the problem here.
24 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Is your feature request related to a problem? Please describe.**
11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12 |
13 | **Describe the solution you'd like**
14 | A clear and concise description of what you want to happen.
15 |
16 | **Describe alternatives you've considered**
17 | A clear and concise description of any alternative solutions or features you've considered.
18 |
19 | **Additional context**
20 | Add any other context or screenshots about the feature request here.
21 |
--------------------------------------------------------------------------------
/RestSQL.NPoco.Tests/RestSQL.NPoco.Tests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp3.1
5 |
6 | false
7 |
8 | wareboss.com
9 |
10 | 1.0.8
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/RestSQL/RestSQL.cs:
--------------------------------------------------------------------------------
1 | using Antlr4.Runtime;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Text;
5 |
6 | namespace RestSQL
7 | {
8 | public static class RestSQL
9 | {
10 | public static T Parse(string query, IExpressionBuilder expressionBuilder)
11 | {
12 | var lexer = new RsqlLexer(new AntlrInputStream(query));
13 | var tokenStream = new CommonTokenStream(lexer);
14 | var rsqlParser = new RsqlParser(tokenStream);
15 | var tree = rsqlParser.expression();
16 | var rsqlStatement = new RsqlExpressionVisitor(expressionBuilder).Visit(tree);
17 |
18 | return rsqlStatement;
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/RestSQL.Tests/RestSQL.Tests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp3.1
5 |
6 | false
7 |
8 | 7.3
9 |
10 | 1.0.8
11 |
12 | wareboss.com
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/RestSQL.SqlKata.Tests/RestSQL.SqlKata.Tests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp3.1
5 |
6 | false
7 |
8 | wareboss.com
9 |
10 | 1.0.8
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/RestSQL.NPoco.Tests/UnitTest1.cs:
--------------------------------------------------------------------------------
1 | using NPoco;
2 | using System;
3 | using Xunit;
4 |
5 | namespace RestSQL.NPoco.Tests
6 | {
7 | public class UnitTest1
8 | {
9 | [Fact]
10 | public void Test1()
11 | {
12 | var testExpressionBuilder = new NPocoBuilder();
13 |
14 | var q = testExpressionBuilder.Build("ab > 'DE' and (c = d or d > 4.3) and e>4 or rere in (20,30,40,50) and defer between 2 and 3 or rerer not in ('432','234324')");
15 |
16 | Assert.Equal("ab > @0 AND ( c = @1 OR d > @2 ) AND e > @3 OR rere IN (@4,@5,@6,@7) AND defer BETWEEN @8 AND @9 OR rerer NOT IN (@10,@11)", q.Sql);
17 | Assert.Equal("DE, d, 4.3, 4, 20, 30, 40, 50, 2, 3, 432, 234324", string.Join(", ", q.Params));
18 |
19 | var s = new SqlBuilder();
20 | s.Where("ab > 'DE' and (c = d or d > 4.3) and e>4 or rere in (20,30,40,50) and defer between 2 and 3 or rerer not in ('432','234324')");
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/.github/workflows/nuget.yml:
--------------------------------------------------------------------------------
1 | name: Publish Packages - RestSQL
2 |
3 | on:
4 | push:
5 | branches: [ master ]
6 |
7 | jobs:
8 | build:
9 | runs-on: ubuntu-latest
10 |
11 | steps:
12 | - uses: actions/checkout@v2
13 | - name: Setup .NET Core
14 | uses: actions/setup-dotnet@v1
15 | with:
16 | dotnet-version: 3.1.101
17 | - name: Install dependencies
18 | run: dotnet restore
19 | - name: Build
20 | run: dotnet build --configuration Release --no-restore
21 | - name: Publish RestSQL
22 | uses: brandedoutcast/publish-nuget@v2.5.2
23 | with:
24 | PROJECT_FILE_PATH: RestSQL/RestSQL.csproj
25 | NUGET_KEY: ${{secrets.NUGET_API_KEY}}
26 | - name: Publish RestSQL.NPoco
27 | uses: brandedoutcast/publish-nuget@v2.5.2
28 | with:
29 | PROJECT_FILE_PATH: RestSQL.NPoco/RestSQL.NPoco.csproj
30 | NUGET_KEY: ${{secrets.NUGET_API_KEY}}
31 | - name: Publish RestSQL.SqlKata
32 | uses: brandedoutcast/publish-nuget@v2.5.2
33 | with:
34 | PROJECT_FILE_PATH: RestSQL.SqlKata/RestSQL.SqlKata.csproj
35 | NUGET_KEY: ${{secrets.NUGET_API_KEY}}
36 |
--------------------------------------------------------------------------------
/RestSQL.Tests/Providers/TestExpression.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Linq;
3 |
4 | namespace RestQL.Tests.Providers
5 | {
6 | public class TestExpression
7 | {
8 | private readonly string whereClause;
9 | private readonly IReadOnlyCollection