Skip to content

Commit 5d9354b

Browse files
Merge branch 'master' into master
2 parents 997837c + 96e54f3 commit 5d9354b

Some content is hidden

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

63 files changed

+3304
-2297
lines changed

.editorconfig

Lines changed: 0 additions & 5 deletions
This file was deleted.

.github/FUNDING.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# These are supported funding model platforms
2+
3+
github: ['ahmad-moussawi']
4+
patreon: # Replace with a single Patreon username
5+
open_collective: sqlkata
6+
ko_fi: # Replace with a single Ko-fi username
7+
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8+
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9+
liberapay: # Replace with a single Liberapay username
10+
issuehunt: # Replace with a single IssueHunt username
11+
otechie: # Replace with a single Otechie username
12+
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']

.github/workflows/build.yml

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
name: .NET Core
2+
on:
3+
push:
4+
pull_request:
5+
release:
6+
types:
7+
- published
8+
env:
9+
# Stop wasting time caching packages
10+
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
11+
# Disable sending usage data to Microsoft
12+
DOTNET_CLI_TELEMETRY_OPTOUT: true
13+
# Project name to pack and publish
14+
PROJECT_NAME: SqlKata
15+
DOTNET_VERSION: 5.0.201
16+
# DOTNET_VERSION: 2.2.203
17+
# GitHub Packages Feed settings
18+
GITHUB_FEED: https://nuget.pkg.github.com/sqlkata/
19+
GITHUB_USER: ahmad-moussawi
20+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
21+
# Official NuGet Feed settings
22+
NUGET_FEED: https://api.nuget.org/v3/index.json
23+
NUGET_KEY: ${{ secrets.NUGET_KEY }}
24+
jobs:
25+
build:
26+
runs-on: ${{ matrix.os }}
27+
strategy:
28+
matrix:
29+
os: [ ubuntu-latest ]
30+
steps:
31+
- name: Checkout
32+
uses: actions/checkout@v2
33+
- name: Setup .NET Core
34+
uses: actions/setup-dotnet@v1
35+
with:
36+
dotnet-version: ${{ env.DOTNET_VERSION }}
37+
- name: Restore
38+
run: dotnet restore
39+
- name: Build
40+
run: dotnet build -c Release --no-restore
41+
- name: Test
42+
run: dotnet test -c Release
43+
- name: Pack QueryBuilder
44+
if: matrix.os == 'ubuntu-latest'
45+
run: dotnet pack -v normal -c Release --no-restore --include-symbols --include-source -p:PackageVersion=$GITHUB_RUN_ID QueryBuilder/QueryBuilder.csproj
46+
- name: Pack SqlKata.Execution
47+
if: matrix.os == 'ubuntu-latest'
48+
run: dotnet pack -v normal -c Release --no-restore --include-symbols --include-source -p:PackageVersion=$GITHUB_RUN_ID SqlKata.Execution/SqlKata.Execution.csproj
49+
- name: Upload QueryBuilder Artifact
50+
if: matrix.os == 'ubuntu-latest'
51+
uses: actions/upload-artifact@v2
52+
with:
53+
name: nupkg
54+
path: ./QueryBuilder/bin/Release/*.nupkg
55+
- name: Upload SqlKata.Execution Artifact
56+
if: matrix.os == 'ubuntu-latest'
57+
uses: actions/upload-artifact@v2
58+
with:
59+
name: nupkg
60+
path: ./SqlKata.Execution/bin/Release/*.nupkg
61+
prerelease:
62+
needs: build
63+
if: github.ref == 'refs/heads/develop'
64+
runs-on: ubuntu-latest
65+
steps:
66+
- name: Download Artifact
67+
uses: actions/download-artifact@v1
68+
with:
69+
name: nupkg
70+
- name: Push to GitHub Feed
71+
run: |
72+
for f in ./nupkg/*.nupkg
73+
do
74+
if [[ ${f} != *".symbols."* ]];then
75+
echo "Uploading package $f" to $GITHUB_FEED
76+
dotnet nuget push $f --api-key=$GITHUB_TOKEN --source=$GITHUB_FEED
77+
fi
78+
# curl -X PUT -u "$GITHUB_USER:$GITHUB_TOKEN" -F package=@$f $GITHUB_FEED
79+
done
80+
deploy:
81+
needs: build
82+
if: github.event_name == 'release'
83+
runs-on: ubuntu-latest
84+
steps:
85+
- uses: actions/checkout@v2
86+
- name: Setup .NET Core
87+
uses: actions/setup-dotnet@v1
88+
with:
89+
dotnet-version: ${{ env.DOTNET_VERSION }}
90+
- name: Create Release NuGet package (QueryBuilder)
91+
run: |
92+
arrTag=(${GITHUB_REF//\// })
93+
VERSION="${arrTag[2]}"
94+
echo Version: $VERSION
95+
VERSION="${VERSION//v}"
96+
echo Clean Version: $VERSION
97+
dotnet pack -v normal -c Release --include-symbols --include-source -p:PackageVersion=$VERSION -o nupkg QueryBuilder/QueryBuilder.csproj
98+
- name: Create Release NuGet package (SqlKata.Execution)
99+
run: |
100+
arrTag=(${GITHUB_REF//\// })
101+
VERSION="${arrTag[2]}"
102+
echo Version: $VERSION
103+
VERSION="${VERSION//v}"
104+
echo Clean Version: $VERSION
105+
dotnet pack -v normal -c Release --include-symbols --include-source -p:PackageVersion=$VERSION -o nupkg SqlKata.Execution/SqlKata.Execution.csproj
106+
- name: Push to GitHub Feed
107+
run: dotnet nuget push ./nupkg/*.nupkg --skip-duplicate --source $GITHUB_FEED --api-key $GITHUB_TOKEN
108+
- name: Push to NuGet Feed
109+
run: dotnet nuget push ./nupkg/*.nupkg --skip-duplicate --source $NUGET_FEED --api-key $NUGET_KEY

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*.pfx
66
npm-debug.log
77
Program/node_modules
8+
*.db
89

910
# User-specific files
1011
*.suo

.travis.yml

Lines changed: 0 additions & 11 deletions
This file was deleted.

Directory.build.props

Lines changed: 0 additions & 39 deletions
This file was deleted.

Program/Demo.db

-8 KB
Binary file not shown.

Program/Program.cs

Lines changed: 62 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
using System.Data;
1212
using Dapper;
1313
using System.Data.SQLite;
14+
using static SqlKata.Expressions;
15+
using System.IO;
1416

1517
namespace Program
1618
{
@@ -32,50 +34,80 @@ private class Installment
3234

3335
static void Main(string[] args)
3436
{
37+
using (var db = SqlLiteQueryFactory())
38+
{
39+
var query = db.Query("accounts")
40+
.Where("balance", ">", 0)
41+
.GroupBy("balance")
42+
.Limit(10);
3543

36-
IDbConnection connection = new SqlConnection(
37-
"Server=tcp:localhost,1433;Initial Catalog=Lite;User ID=sa;Password=P@ssw0rd"
38-
);
44+
var accounts = query.Clone().Get();
45+
Console.WriteLine(JsonConvert.SerializeObject(accounts, Formatting.Indented));
3946

40-
// SQLiteConnection.CreateFile("Demo.db");
47+
var exists = query.Clone().Exists();
48+
Console.WriteLine(exists);
49+
}
50+
}
4151

42-
// connection = new SQLiteConnection("Data Source=Demo.db");
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+
}
4358

44-
var db = new QueryFactory(connection, new SqlServerCompiler());
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);
4566

4667
db.Logger = result =>
4768
{
4869
Console.WriteLine(result.ToString());
4970
};
5071

51-
/*
52-
var accounts = db.Query("Accounts")
53-
.WhereNotNull("BankId")
54-
.Include("bank",
55-
db.Query("Banks").Include("Country", db.Query("Countries"))
56-
.Select("Id", "Name", "CountryId")
57-
)
58-
.Select("Id", "Name", "BankId")
59-
.OrderByDesc("Id").Limit(10).Get();
60-
*/
61-
62-
var includedAccountsQuery = db.Query("Accounts").Limit(2)
63-
.IncludeMany("Transactions", db.Query("Transactions"))
64-
.Include("Company", db.Query("Companies"));
65-
66-
var bank = db.Query("Banks as Icon")
67-
.IncludeMany("Accounts", includedAccountsQuery, "BankId")
68-
.WhereExists(q => q.From("Accounts").WhereColumns("Accounts.BankId", "=", "Icon.Id"))
69-
.Limit(1)
70-
.Get();
71-
72-
Console.WriteLine(JsonConvert.SerializeObject(bank, Formatting.Indented));
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;
7393

7494
}
7595

76-
private static void log(Compiler compiler, Query query)
96+
private static QueryFactory SqlServerQueryFactory()
7797
{
78-
Console.WriteLine(compiler.Compile(query).ToString());
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;
79111
}
80112

81113
}

Program/index.js

Lines changed: 0 additions & 16 deletions
This file was deleted.

Program/package.json

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)