Skip to content

Commit 537d8bd

Browse files
Merge branch 'master' into feature/where-boolean
2 parents 809fb28 + 4e3d2ae commit 537d8bd

File tree

76 files changed

+421
-366
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+421
-366
lines changed

.editorconfig

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
# Note: the trim_trailing_whitespace option is br0ken in visualstudio, it
7+
# simply does not follow the EditorConfig specification. Therefor you are
8+
# strongly encouraged to not rely on this setting alone, but please install
9+
# the following extension too: https://marketplace.visualstudio.com/items?itemName=MadsKristensen.TrailingWhitespaceVisualizer
10+
#
11+
# References:
12+
# https://developercommunity.visualstudio.com/t/EditorConfig:-trim_trailing_whitespace-d/1240174?space=8&q=trim_trailing_whitespace
13+
# https://developercommunity.visualstudio.com/t/editorconfig-trim_trailing_whitespace-on/134457?space=8&q=trim_trailing_whitespace
14+
# https://developercommunity.visualstudio.com/t/trim_trailing_whitespace-in-editorconfi/1351034?space=8&q=trim_trailing_whitespace
15+
# https://developercommunity.visualstudio.com/t/BUG:-editorconfig-trim_trailing_whitespa/953937?space=8&q=trim_trailing_whitespace
16+
trim_trailing_whitespace = true
17+
insert_final_newline = true
18+
indent_style = tab
19+
indent_size = 2
20+
21+
22+
[*.cs] # To match existing style
23+
indent_style = space
24+
indent_size = 4
25+
26+
27+
[*.yml]
28+
indent_style = space

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,4 +112,4 @@ jobs:
112112
- name: Push to GitHub Feed
113113
run: dotnet nuget push ./nupkg/*.nupkg --skip-duplicate --source $GITHUB_FEED --api-key $GITHUB_TOKEN
114114
- name: Push to NuGet Feed
115-
run: dotnet nuget push ./nupkg/*.nupkg --skip-duplicate --source $NUGET_FEED --api-key $NUGET_KEY
115+
run: dotnet nuget push ./nupkg/*.nupkg --skip-duplicate --source $NUGET_FEED --api-key $NUGET_KEY

.vscode/launch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@
2525
"processId": "${command:pickProcess}"
2626
}
2727
,]
28-
}
28+
}

.vscode/tasks.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
"problemMatcher": "$msCompile"
1313
}
1414
]
15-
}
15+
}

Program/Program.cs

Lines changed: 114 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -1,114 +1,114 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using SqlKata;
4-
using SqlKata.Compilers;
5-
using SqlKata.Execution;
6-
using System.Data.SqlClient;
7-
using System.Threading.Tasks;
8-
using System.Linq;
9-
using Newtonsoft.Json;
10-
using Npgsql;
11-
using System.Data;
12-
using Dapper;
13-
using System.Data.SQLite;
14-
using static SqlKata.Expressions;
15-
using System.IO;
16-
17-
namespace Program
18-
{
19-
class Program
20-
{
21-
private class Loan
22-
{
23-
public string Id { get; set; }
24-
public string Name { get; set; }
25-
public List<Installment> Installments { get; set; } = new List<Installment>();
26-
}
27-
28-
private class Installment
29-
{
30-
public string Id { get; set; }
31-
public string LoanId { get; set; }
32-
public int DaysCount { get; set; }
33-
}
34-
35-
static void Main(string[] args)
36-
{
37-
using (var db = SqlLiteQueryFactory())
38-
{
39-
var query = db.Query("accounts")
40-
.Where("balance", ">", 0)
41-
.GroupBy("balance")
42-
.Limit(10);
43-
44-
var accounts = query.Clone().Get();
45-
Console.WriteLine(JsonConvert.SerializeObject(accounts, Formatting.Indented));
46-
47-
var exists = query.Clone().Exists();
48-
Console.WriteLine(exists);
49-
}
50-
}
51-
52-
private static void log(Compiler compiler, Query query)
53-
{
54-
var compiled = compiler.Compile(query);
55-
Console.WriteLine(compiled.ToString());
56-
Console.WriteLine(JsonConvert.SerializeObject(compiled.Bindings));
57-
}
58-
59-
private static QueryFactory SqlLiteQueryFactory()
60-
{
61-
var compiler = new SqliteCompiler();
62-
63-
var connection = new SQLiteConnection("Data Source=Demo.db");
64-
65-
var db = new QueryFactory(connection, compiler);
66-
67-
db.Logger = result =>
68-
{
69-
Console.WriteLine(result.ToString());
70-
};
71-
72-
if (!File.Exists("Demo.db"))
73-
{
74-
Console.WriteLine("db not exists creating db");
75-
76-
SQLiteConnection.CreateFile("Demo.db");
77-
78-
db.Statement("create table accounts(id integer primary key autoincrement, name varchar, currency_id varchar, balance decimal, created_at datetime);");
79-
for (var i = 0; i < 10; i++)
80-
{
81-
db.Statement("insert into accounts(name, currency_id, balance, created_at) values(@name, @currency, @balance, @date)", new
82-
{
83-
name = $"Account {i}",
84-
currency = "USD",
85-
balance = 100 * i * 1.1,
86-
date = DateTime.UtcNow,
87-
});
88-
}
89-
90-
}
91-
92-
return db;
93-
94-
}
95-
96-
private static QueryFactory SqlServerQueryFactory()
97-
{
98-
var compiler = new PostgresCompiler();
99-
var connection = new SqlConnection(
100-
"Server=tcp:localhost,1433;Initial Catalog=Lite;User ID=sa;Password=P@ssw0rd"
101-
);
102-
103-
var db = new QueryFactory(connection, compiler);
104-
105-
db.Logger = result =>
106-
{
107-
Console.WriteLine(result.ToString());
108-
};
109-
110-
return db;
111-
}
112-
113-
}
114-
}
1+
using System;
2+
using System.Collections.Generic;
3+
using SqlKata;
4+
using SqlKata.Compilers;
5+
using SqlKata.Execution;
6+
using System.Data.SqlClient;
7+
using System.Threading.Tasks;
8+
using System.Linq;
9+
using Newtonsoft.Json;
10+
using Npgsql;
11+
using System.Data;
12+
using Dapper;
13+
using System.Data.SQLite;
14+
using static SqlKata.Expressions;
15+
using System.IO;
16+
17+
namespace Program
18+
{
19+
class Program
20+
{
21+
private class Loan
22+
{
23+
public string Id { get; set; }
24+
public string Name { get; set; }
25+
public List<Installment> Installments { get; set; } = new List<Installment>();
26+
}
27+
28+
private class Installment
29+
{
30+
public string Id { get; set; }
31+
public string LoanId { get; set; }
32+
public int DaysCount { get; set; }
33+
}
34+
35+
static void Main(string[] args)
36+
{
37+
using (var db = SqlLiteQueryFactory())
38+
{
39+
var query = db.Query("accounts")
40+
.Where("balance", ">", 0)
41+
.GroupBy("balance")
42+
.Limit(10);
43+
44+
var accounts = query.Clone().Get();
45+
Console.WriteLine(JsonConvert.SerializeObject(accounts, Formatting.Indented));
46+
47+
var exists = query.Clone().Exists();
48+
Console.WriteLine(exists);
49+
}
50+
}
51+
52+
private static void log(Compiler compiler, Query query)
53+
{
54+
var compiled = compiler.Compile(query);
55+
Console.WriteLine(compiled.ToString());
56+
Console.WriteLine(JsonConvert.SerializeObject(compiled.Bindings));
57+
}
58+
59+
private static QueryFactory SqlLiteQueryFactory()
60+
{
61+
var compiler = new SqliteCompiler();
62+
63+
var connection = new SQLiteConnection("Data Source=Demo.db");
64+
65+
var db = new QueryFactory(connection, compiler);
66+
67+
db.Logger = result =>
68+
{
69+
Console.WriteLine(result.ToString());
70+
};
71+
72+
if (!File.Exists("Demo.db"))
73+
{
74+
Console.WriteLine("db not exists creating db");
75+
76+
SQLiteConnection.CreateFile("Demo.db");
77+
78+
db.Statement("create table accounts(id integer primary key autoincrement, name varchar, currency_id varchar, balance decimal, created_at datetime);");
79+
for (var i = 0; i < 10; i++)
80+
{
81+
db.Statement("insert into accounts(name, currency_id, balance, created_at) values(@name, @currency, @balance, @date)", new
82+
{
83+
name = $"Account {i}",
84+
currency = "USD",
85+
balance = 100 * i * 1.1,
86+
date = DateTime.UtcNow,
87+
});
88+
}
89+
90+
}
91+
92+
return db;
93+
94+
}
95+
96+
private static QueryFactory SqlServerQueryFactory()
97+
{
98+
var compiler = new PostgresCompiler();
99+
var connection = new SqlConnection(
100+
"Server=tcp:localhost,1433;Initial Catalog=Lite;User ID=sa;Password=P@ssw0rd"
101+
);
102+
103+
var db = new QueryFactory(connection, compiler);
104+
105+
db.Logger = result =>
106+
{
107+
Console.WriteLine(result.ToString());
108+
};
109+
110+
return db;
111+
}
112+
113+
}
114+
}

QueryBuilder.Tests/AggregateTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using SqlKata.Compilers;
1+
using SqlKata.Compilers;
22
using SqlKata.Tests.Infrastructure;
33
using Xunit;
44

QueryBuilder.Tests/DefineTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using static SqlKata.Expressions;
1+
using static SqlKata.Expressions;
22
using SqlKata.Compilers;
33
using SqlKata.Tests.Infrastructure;
44
using Xunit;

QueryBuilder.Tests/ExecutionTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using SqlKata.Execution;
33
using Xunit;
44

@@ -15,4 +15,4 @@ public void ShouldThrowException()
1515
});
1616
}
1717
}
18-
}
18+
}

QueryBuilder.Tests/Firebird/FirebirdLimitTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public FirebirdLimitTests()
1717
public void NoLimitNorOffset()
1818
{
1919
var query = new Query("Table");
20-
var ctx = new SqlResult {Query = query};
20+
var ctx = new SqlResult { Query = query };
2121

2222
Assert.Null(compiler.CompileLimit(ctx));
2323
}
@@ -26,7 +26,7 @@ public void NoLimitNorOffset()
2626
public void LimitOnly()
2727
{
2828
var query = new Query("Table").Limit(10);
29-
var ctx = new SqlResult {Query = query};
29+
var ctx = new SqlResult { Query = query };
3030

3131
Assert.Null(compiler.CompileLimit(ctx));
3232
}
@@ -35,7 +35,7 @@ public void LimitOnly()
3535
public void OffsetOnly()
3636
{
3737
var query = new Query("Table").Offset(20);
38-
var ctx = new SqlResult {Query = query};
38+
var ctx = new SqlResult { Query = query };
3939

4040
Assert.Null(compiler.CompileLimit(ctx));
4141
}
@@ -44,12 +44,12 @@ public void OffsetOnly()
4444
public void LimitAndOffset()
4545
{
4646
var query = new Query("Table").Limit(5).Offset(20);
47-
var ctx = new SqlResult {Query = query};
47+
var ctx = new SqlResult { Query = query };
4848

4949
Assert.Equal("ROWS ? TO ?", compiler.CompileLimit(ctx));
5050
Assert.Equal(21, ctx.Bindings[0]);
5151
Assert.Equal(25, ctx.Bindings[1]);
5252
Assert.Equal(2, ctx.Bindings.Count);
5353
}
5454
}
55-
}
55+
}

QueryBuilder.Tests/HelperTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,4 +234,4 @@ public void WrapIdentifiers(string input, string escapeCharacter, string identif
234234
Assert.Equal(expected, result);
235235
}
236236
}
237-
}
237+
}

0 commit comments

Comments
 (0)