Skip to content

Commit a108338

Browse files
Merge branch 'master' of https://github.com/sqlkata/querybuilder
2 parents df5935c + c202922 commit a108338

File tree

4 files changed

+60
-10
lines changed

4 files changed

+60
-10
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# This workflow was added by CodeSee. Learn more at https://codesee.io/
2+
# This is v2.0 of this workflow file
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request_target:
8+
types: [opened, synchronize, reopened]
9+
10+
name: CodeSee
11+
12+
permissions: read-all
13+
14+
jobs:
15+
codesee:
16+
runs-on: ubuntu-latest
17+
continue-on-error: true
18+
name: Analyze the repo with CodeSee
19+
steps:
20+
- uses: Codesee-io/codesee-action@v2
21+
with:
22+
codesee-token: ${{ secrets.CODESEE_ARCH_DIAG_API_TOKEN }}
23+
codesee-url: https://app.codesee.io

QueryBuilder.Tests/SelectTests.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,20 @@ public void ExpandedSelect()
7474
Assert.Equal("SELECT `users`.`id`, `users`.`name`, `users`.`age` FROM `users`", c[EngineCodes.MySql]);
7575
}
7676

77+
[Fact]
78+
public void ExpandedSelectMultiline()
79+
{
80+
var q = new Query().From("users").Select(@"users.{
81+
id,
82+
name as Name,
83+
age
84+
}");
85+
var c = Compile(q);
86+
87+
Assert.Equal("SELECT [users].[id], [users].[name] AS [Name], [users].[age] FROM [users]", c[EngineCodes.SqlServer]);
88+
Assert.Equal("SELECT `users`.`id`, `users`.`name` AS `Name`, `users`.`age` FROM `users`", c[EngineCodes.MySql]);
89+
}
90+
7791
[Fact]
7892
public void ExpandedSelectWithSchema()
7993
{
@@ -83,6 +97,19 @@ public void ExpandedSelectWithSchema()
8397
Assert.Equal("SELECT [dbo].[users].[id], [dbo].[users].[name], [dbo].[users].[age] FROM [users]", c[EngineCodes.SqlServer]);
8498
}
8599

100+
[Fact]
101+
public void ExpandedSelectMultilineWithSchema()
102+
{
103+
var q = new Query().From("users").Select(@"dbo.users.{
104+
id,
105+
name as Name,
106+
age
107+
}");
108+
var c = Compile(q);
109+
110+
Assert.Equal("SELECT [dbo].[users].[id], [dbo].[users].[name] AS [Name], [dbo].[users].[age] FROM [users]", c[EngineCodes.SqlServer]);
111+
}
112+
86113
[Fact]
87114
public void NestedEmptyWhereAtFirstCondition()
88115
{

QueryBuilder/Helper.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ public static int EnumerableCount(IEnumerable obj)
139139

140140
public static List<string> ExpandExpression(string expression)
141141
{
142-
var regex = @"^(?:\w+\.){1,2}{(.*)}";
143-
var match = Regex.Match(expression, regex);
142+
var regex = @"^(?:\w+\.){1,2}{([^}]*)}";
143+
var match = Regex.Match(expression, regex, RegexOptions.Multiline);
144144

145145
if (!match.Success)
146146
{
@@ -152,7 +152,7 @@ public static List<string> ExpandExpression(string expression)
152152

153153
var captures = match.Groups[1].Value;
154154

155-
var cols = Regex.Split(captures, @"\s*,\s*")
155+
var cols = Regex.Split(captures, @"\s*,\s*", RegexOptions.Multiline)
156156
.Select(x => $"{table}.{x.Trim()}")
157157
.ToList();
158158

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@
2323

2424
SqlKata Query Builder is a powerful Sql Query Builder written in C#.
2525

26-
It's secure and framework agnostic. Inspired by the top Query Builders available, like Laravel Query Builder, and Knex.
26+
It's secure and framework agnostic. Inspired by the top Query Builders available, like Laravel Query Builder and Knex.
2727

2828
SqlKata has an expressive API. it follows a clean naming convention, which is very similar to the SQL syntax.
2929

3030
By providing a level of abstraction over the supported database engines, that allows you to work with multiple databases with the same unified API.
3131

32-
SqlKata supports complex queries, such as nested conditions, selection from SubQuery, filtering over SubQueries, Conditional Statements and others. Currently it has built-in compilers for SqlServer, MySql, PostgreSql and Firebird.
32+
SqlKata supports complex queries, such as nested conditions, selection from SubQuery, filtering over SubQueries, Conditional Statements and others. Currently, it has built-in compilers for SqlServer, MySql, PostgreSQL, and Firebird.
3333

3434
The SqlKata.Execution package provides the ability to submit the queries to the database, using [Dapper](https://github.com/StackExchange/Dapper) under the covers.
3535

@@ -160,15 +160,15 @@ int affected = db.Query("Users").Where("Id", 1).Delete();
160160

161161
## FAQ
162162
### How to know when a new release or a feature is available?
163-
I announce updates on My [Twitter Account](https://twitter.com/ahmadmuzavi), and you can subscribe to our news letters from the website https://sqlkata.com
163+
I announce updates on My [Twitter Account](https://twitter.com/ahmadmuzavi), and you can subscribe to our newsletters from the website https://sqlkata.com
164164

165-
### The database that I want is not supported why?
166-
Usually it's impossible to support all available database vendors, this why we focus on the major ones, and we are encourage you to create your own compiler for your database
165+
### The database that I want is not supported. Why?
166+
It's impossible to support all available database vendors, this is why we focus on the major ones, and we encourage you to create your own compiler for your database.
167167

168168
### Do you accept new compilers?
169-
Unfortunetly no, the reason is this will add overhead for the project contributors, we prefer to improve the quality of the existing compilers instead
169+
Unfortunately, no, the reason is this will add overhead for the project contributors. We prefer to improve the quality of the existing compilers instead.
170170

171171
### How can I support the project?
172172
- Star the project here in Github, and share it with your friends
173173
- Follow and upvote it on Product Hunt <a href="https://www.producthunt.com/products/sqlkata?utm_source=badge-follow&utm_medium=badge&utm_souce=badge-sqlkata" target="_blank"><img src="https://api.producthunt.com/widgets/embed-image/v1/follow.svg?post_id=398417&theme=light&size=small" alt="SqlKata - Dynamic&#0032;Sql&#0032;query&#0032;builder&#0032;for&#0032;dotnet | Product Hunt" style="width: 86px; height: 32px;" width="250" height="54" /></a>
174-
- You can also donate to support the project financily on open collection.
174+
- You can also donate to support the project financially on open collection.

0 commit comments

Comments
 (0)