Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| fc045d021c | |||
| aa14333604 | |||
| 72c11f77e5 | |||
| caf34e707c | |||
| b96775f1ed | |||
| 91e84a5059 | |||
| 8b1c56d310 | |||
| 6a2b52475f | |||
| ddc7429dc5 | |||
| 3c80c46c91 |
@@ -6,6 +6,9 @@ on:
|
|||||||
pull_request:
|
pull_request:
|
||||||
branches: [ "main" ]
|
branches: [ "main" ]
|
||||||
|
|
||||||
|
env:
|
||||||
|
BBDOX__PG__PORT: 8301
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-and-test:
|
build-and-test:
|
||||||
|
|
||||||
@@ -13,12 +16,13 @@ jobs:
|
|||||||
|
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
dotnet-version: [ "6.0", "7.0", "8.0" ]
|
|
||||||
postgres-version: [ "12", "13", "14", "15", "latest" ]
|
postgres-version: [ "12", "13", "14", "15", "latest" ]
|
||||||
|
|
||||||
services:
|
services:
|
||||||
postgres:
|
postgres:
|
||||||
image: postgres:${{ matrix.postgres-version }}
|
image: postgres:${{ matrix.postgres-version }}
|
||||||
|
networks:
|
||||||
|
- runner_overlay
|
||||||
env:
|
env:
|
||||||
POSTGRES_PASSWORD: postgres
|
POSTGRES_PASSWORD: postgres
|
||||||
options: >-
|
options: >-
|
||||||
@@ -27,20 +31,32 @@ jobs:
|
|||||||
--health-timeout 5s
|
--health-timeout 5s
|
||||||
--health-retries 5
|
--health-retries 5
|
||||||
ports:
|
ports:
|
||||||
- 5432:5432
|
- "8301:5432"
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- name: Setup .NET ${{ matrix.dotnet-version }}.x
|
- name: Setup .NET 6
|
||||||
uses: actions/setup-dotnet@v3
|
uses: actions/setup-dotnet@v3
|
||||||
with:
|
with:
|
||||||
dotnet-version: ${{ matrix.dotnet-version }}.x
|
dotnet-version: "6.0.x"
|
||||||
|
- name: Setup .NET 7
|
||||||
|
uses: actions/setup-dotnet@v3
|
||||||
|
with:
|
||||||
|
dotnet-version: "7.0.x"
|
||||||
|
- name: Setup .NET 8
|
||||||
|
uses: actions/setup-dotnet@v3
|
||||||
|
with:
|
||||||
|
dotnet-version: "8.0.x"
|
||||||
- name: Restore dependencies
|
- name: Restore dependencies
|
||||||
run: dotnet restore src/BitBadger.Documents.sln
|
run: dotnet restore src/BitBadger.Documents.sln
|
||||||
- name: Build
|
- name: Build
|
||||||
run: dotnet build src/BitBadger.Documents.sln --no-restore -f net${{ matrix.dotnet-version }}
|
run: dotnet build src/BitBadger.Documents.sln --no-restore
|
||||||
- name: Test ${{ matrix.dotnet-version }} against PostgreSQL ${{ matrix.postgres-version }}
|
- name: Test .NET 6 against PostgreSQL ${{ matrix.postgres-version }}
|
||||||
run: dotnet run --project src/Tests/BitBadger.Documents.Tests.fsproj -f net${{ matrix.dotnet-version }}
|
run: dotnet run --project src/Tests/BitBadger.Documents.Tests.fsproj -f net6.0
|
||||||
|
- name: Test .NET 7 against PostgreSQL ${{ matrix.postgres-version }}
|
||||||
|
run: dotnet run --project src/Tests/BitBadger.Documents.Tests.fsproj -f net7.0
|
||||||
|
- name: Test .NET 8 against PostgreSQL ${{ matrix.postgres-version }}
|
||||||
|
run: dotnet run --project src/Tests/BitBadger.Documents.Tests.fsproj -f net8.0
|
||||||
publish:
|
publish:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: build-and-test
|
needs: build-and-test
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<PackageReleaseNotes>Added Field type for by-field operations</PackageReleaseNotes>
|
<Description>Common files for PostgreSQL and SQLite document database libraries</Description>
|
||||||
|
<PackageReleaseNotes>v3 release</PackageReleaseNotes>
|
||||||
<PackageTags>JSON Document SQL</PackageTags>
|
<PackageTags>JSON Document SQL</PackageTags>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -6,14 +6,13 @@
|
|||||||
<AssemblyVersion>3.0.0.0</AssemblyVersion>
|
<AssemblyVersion>3.0.0.0</AssemblyVersion>
|
||||||
<FileVersion>3.0.0.0</FileVersion>
|
<FileVersion>3.0.0.0</FileVersion>
|
||||||
<VersionPrefix>3.0.0</VersionPrefix>
|
<VersionPrefix>3.0.0</VersionPrefix>
|
||||||
<VersionSuffix>rc-2</VersionSuffix>
|
|
||||||
<Authors>danieljsummers</Authors>
|
<Authors>danieljsummers</Authors>
|
||||||
<Company>Bit Badger Solutions</Company>
|
<Company>Bit Badger Solutions</Company>
|
||||||
<PackageReadmeFile>README.md</PackageReadmeFile>
|
<PackageReadmeFile>README.md</PackageReadmeFile>
|
||||||
<PackageIcon>icon.png</PackageIcon>
|
<PackageIcon>icon.png</PackageIcon>
|
||||||
<PackageProjectUrl>https://bitbadger.solutions/open-source/relational-documents/</PackageProjectUrl>
|
<PackageProjectUrl>https://bitbadger.solutions/open-source/relational-documents/</PackageProjectUrl>
|
||||||
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
|
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
|
||||||
<RepositoryUrl>https://github.com/bit-badger/BitBadger.Documents</RepositoryUrl>
|
<RepositoryUrl>https://git.bitbadger.solutions/bit-badger/BitBadger.Documents</RepositoryUrl>
|
||||||
<RepositoryType>Git</RepositoryType>
|
<RepositoryType>Git</RepositoryType>
|
||||||
<Copyright>MIT License</Copyright>
|
<Copyright>MIT License</Copyright>
|
||||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<PackageReleaseNotes>Adds Field type for by-field operations (BREAKING from rc-1); adds RemoveFields* functions</PackageReleaseNotes>
|
<Description>Use PostgreSQL as a document database</Description>
|
||||||
|
<PackageReleaseNotes>v3 release; official replacement for BitBadger.Npgsql.Documents</PackageReleaseNotes>
|
||||||
<PackageTags>JSON Document PostgreSQL Npgsql</PackageTags>
|
<PackageTags>JSON Document PostgreSQL Npgsql</PackageTags>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ Retrieve all customers:
|
|||||||
```csharp
|
```csharp
|
||||||
// C#; parameter is table name
|
// C#; parameter is table name
|
||||||
// Find.All type signature is Func<string, Task<List<TDoc>>>
|
// Find.All type signature is Func<string, Task<List<TDoc>>>
|
||||||
var customers = await Find.All("customer");
|
var customers = await Find.All<Customer>("customer");
|
||||||
```
|
```
|
||||||
|
|
||||||
```fsharp
|
```fsharp
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<PackageReleaseNotes>Adds Field type for by-field operations (BREAKING from rc-1); adds RemoveFields* functions</PackageReleaseNotes>
|
<Description>Use SQLite as a document database</Description>
|
||||||
|
<PackageReleaseNotes>Overall v3 release; initial release supporting SQLite</PackageReleaseNotes>
|
||||||
<PackageTags>JSON Document SQLite</PackageTags>
|
<PackageTags>JSON Document SQLite</PackageTags>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ Retrieve all customers:
|
|||||||
```csharp
|
```csharp
|
||||||
// C#; parameter is table name
|
// C#; parameter is table name
|
||||||
// Find.All type signature is Func<string, Task<List<TDoc>>>
|
// Find.All type signature is Func<string, Task<List<TDoc>>>
|
||||||
var customers = await Find.All("customer");
|
var customers = await Find.All<Customer>("customer");
|
||||||
```
|
```
|
||||||
|
|
||||||
```fsharp
|
```fsharp
|
||||||
@@ -72,28 +72,28 @@ Count customers in Atlanta:
|
|||||||
|
|
||||||
```csharp
|
```csharp
|
||||||
// C#; parameters are table name, field, operator, and value
|
// C#; parameters are table name, field, operator, and value
|
||||||
// Count.ByField type signature is Func<string, string, Op, object, Task<long>>
|
// Count.ByField type signature is Func<string, Field, Task<long>>
|
||||||
var customerCount = await Count.ByField("customer", "City", Op.EQ, "Atlanta");
|
var customerCount = await Count.ByField("customer", Field.EQ("City", "Atlanta"));
|
||||||
```
|
```
|
||||||
|
|
||||||
```fsharp
|
```fsharp
|
||||||
// F#
|
// F#
|
||||||
// Count.byField type signature is string -> string -> Op -> obj -> Task<int64>
|
// Count.byField type signature is string -> Field -> Task<int64>
|
||||||
let! customerCount = Count.byField "customer" "City" EQ "Atlanta"
|
let! customerCount = Count.byField "customer" (Field.EQ "City" "Atlanta")
|
||||||
```
|
```
|
||||||
|
|
||||||
Delete customers in Chicago: _(no offense, Second City; just an example...)_
|
Delete customers in Chicago: _(no offense, Second City; just an example...)_
|
||||||
|
|
||||||
```csharp
|
```csharp
|
||||||
// C#; parameters are same as above, except return is void
|
// C#; parameters are same as above, except return is void
|
||||||
// Delete.ByField type signature is Func<string, string, Op, object, Task>
|
// Delete.ByField type signature is Func<string, Field, Task>
|
||||||
await Delete.ByField("customer", "City", Op.EQ, "Chicago");
|
await Delete.ByField("customer", Field.EQ("City", "Chicago"));
|
||||||
```
|
```
|
||||||
|
|
||||||
```fsharp
|
```fsharp
|
||||||
// F#
|
// F#
|
||||||
// Delete.byField type signature is string -> string -> Op -> obj -> Task<unit>
|
// Delete.byField type signature is string -> string -> Op -> obj -> Task<unit>
|
||||||
do! Delete.byField "customer" "City" EQ "Chicago"
|
do! Delete.byField "customer" (Field.EQ "City" "Chicago")
|
||||||
```
|
```
|
||||||
|
|
||||||
## More Information
|
## More Information
|
||||||
|
|||||||
@@ -53,65 +53,55 @@ public static class PostgresDb
|
|||||||
/// The host for the database
|
/// The host for the database
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private static readonly Lazy<string> DbHost = new(() =>
|
private static readonly Lazy<string> DbHost = new(() =>
|
||||||
{
|
Environment.GetEnvironmentVariable("BBDOX_PG_HOST") switch
|
||||||
return Environment.GetEnvironmentVariable("BitBadger.Documents.Postgres.DbHost") switch
|
|
||||||
{
|
{
|
||||||
null => "localhost",
|
null => "localhost",
|
||||||
var host when host.Trim() == "" => "localhost",
|
var host when host.Trim() == "" => "localhost",
|
||||||
var host => host
|
var host => host
|
||||||
};
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The port for the database
|
/// The port for the database
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private static readonly Lazy<int> DbPort = new(() =>
|
private static readonly Lazy<int> DbPort = new(() =>
|
||||||
{
|
Environment.GetEnvironmentVariable("BBDOX_PG_PORT") switch
|
||||||
return Environment.GetEnvironmentVariable("BitBadger.Documents.Postgres.DbPort") switch
|
|
||||||
{
|
{
|
||||||
null => 5432,
|
null => 5432,
|
||||||
var port when port.Trim() == "" => 5432,
|
var port when port.Trim() == "" => 5432,
|
||||||
var port => int.Parse(port)
|
var port => int.Parse(port)
|
||||||
};
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The database itself
|
/// The database itself
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private static readonly Lazy<string> DbDatabase = new(() =>
|
private static readonly Lazy<string> DbDatabase = new(() =>
|
||||||
{
|
Environment.GetEnvironmentVariable("BBDOX_PG_DATABASE") switch
|
||||||
return Environment.GetEnvironmentVariable("BitBadger.Documents.Postres.DbDatabase") switch
|
|
||||||
{
|
{
|
||||||
null => "postgres",
|
null => "postgres",
|
||||||
var db when db.Trim() == "" => "postgres",
|
var db when db.Trim() == "" => "postgres",
|
||||||
var db => db
|
var db => db
|
||||||
};
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The user to use in connecting to the database
|
/// The user to use in connecting to the database
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private static readonly Lazy<string> DbUser = new(() =>
|
private static readonly Lazy<string> DbUser = new(() =>
|
||||||
{
|
Environment.GetEnvironmentVariable("BBDOX_PG_USER") switch
|
||||||
return Environment.GetEnvironmentVariable("BitBadger.Documents.Postgres.DbUser") switch
|
|
||||||
{
|
{
|
||||||
null => "postgres",
|
null => "postgres",
|
||||||
var user when user.Trim() == "" => "postgres",
|
var user when user.Trim() == "" => "postgres",
|
||||||
var user => user
|
var user => user
|
||||||
};
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The password to use for the database
|
/// The password to use for the database
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private static readonly Lazy<string> DbPassword = new(() =>
|
private static readonly Lazy<string> DbPassword = new(() =>
|
||||||
{
|
Environment.GetEnvironmentVariable("BBDOX_PG_PWD") switch
|
||||||
return Environment.GetEnvironmentVariable("BitBadger.Documents.Postrgres.DbPwd") switch
|
|
||||||
{
|
{
|
||||||
null => "postgres",
|
null => "postgres",
|
||||||
var pwd when pwd.Trim() == "" => "postgres",
|
var pwd when pwd.Trim() == "" => "postgres",
|
||||||
var pwd => pwd
|
var pwd => pwd
|
||||||
};
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -1,19 +1,27 @@
|
|||||||
open Expecto
|
open Expecto
|
||||||
open BitBadger.Documents.Tests.CSharp
|
open BitBadger.Documents.Tests.CSharp
|
||||||
|
|
||||||
|
let postgresOnly =
|
||||||
|
match System.Environment.GetEnvironmentVariable "BBDOX_PG_ONLY" with
|
||||||
|
| null -> false
|
||||||
|
| "true" -> true
|
||||||
|
| _ -> false
|
||||||
|
|
||||||
let allTests =
|
let allTests =
|
||||||
testList
|
testList "BitBadger.Documents" [
|
||||||
"BitBadger.Documents"
|
if not postgresOnly then
|
||||||
[ CommonTests.all
|
CommonTests.all
|
||||||
CommonCSharpTests.Unit
|
CommonCSharpTests.Unit
|
||||||
PostgresTests.all
|
PostgresTests.all
|
||||||
PostgresCSharpTests.All
|
PostgresCSharpTests.All
|
||||||
PostgresExtensionTests.integrationTests
|
PostgresExtensionTests.integrationTests
|
||||||
testSequenced PostgresCSharpExtensionTests.Integration
|
testSequenced PostgresCSharpExtensionTests.Integration
|
||||||
|
if not postgresOnly then
|
||||||
SqliteTests.all
|
SqliteTests.all
|
||||||
SqliteCSharpTests.All
|
SqliteCSharpTests.All
|
||||||
SqliteExtensionTests.integrationTests
|
SqliteExtensionTests.integrationTests
|
||||||
testSequenced SqliteCSharpExtensionTests.Integration ]
|
testSequenced SqliteCSharpExtensionTests.Integration
|
||||||
|
]
|
||||||
|
|
||||||
[<EntryPoint>]
|
[<EntryPoint>]
|
||||||
let main args = runTestsWithCLIArgs [] args allTests
|
let main args = runTestsWithCLIArgs [] args allTests
|
||||||
|
|||||||
13
src/package.sh
Executable file
13
src/package.sh
Executable file
@@ -0,0 +1,13 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
echo --- Package Common library
|
||||||
|
dotnet pack Common/BitBadger.Documents.Common.fsproj -c Release
|
||||||
|
cp Common/bin/Release/BitBadger.Documents.Common.*.nupkg .
|
||||||
|
|
||||||
|
echo --- Package PostgreSQL library
|
||||||
|
dotnet pack Postgres/BitBadger.Documents.Postgres.fsproj -c Release
|
||||||
|
cp Postgres/bin/Release/BitBadger.Documents.Postgres.*.nupkg .
|
||||||
|
|
||||||
|
echo --- Package SQLite library
|
||||||
|
dotnet pack Sqlite/BitBadger.Documents.Sqlite.fsproj -c Release
|
||||||
|
cp Sqlite/bin/Release/BitBadger.Documents.Sqlite.*.nupkg .
|
||||||
33
src/test_all.sh
Executable file
33
src/test_all.sh
Executable file
@@ -0,0 +1,33 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
dotnet clean BitBadger.Documents.sln
|
||||||
|
dotnet restore BitBadger.Documents.sln
|
||||||
|
dotnet build BitBadger.Documents.sln --no-restore
|
||||||
|
|
||||||
|
cd ./Tests || exit
|
||||||
|
|
||||||
|
export BBDOX_PG_PORT=8301
|
||||||
|
PG_VERSIONS=('12' '13' '14' '15' 'latest')
|
||||||
|
NET_VERSIONS=('6.0' '7.0' '8.0')
|
||||||
|
|
||||||
|
for PG_VERSION in "${PG_VERSIONS[@]}"
|
||||||
|
do
|
||||||
|
echo Starting PostgreSQL:$PG_VERSION
|
||||||
|
docker run -d -p $BBDOX_PG_PORT:5432 --name pg_test -e POSTGRES_PASSWORD=postgres postgres:$PG_VERSION
|
||||||
|
sleep 4
|
||||||
|
for NET_VERSION in "${NET_VERSIONS[@]}"
|
||||||
|
do
|
||||||
|
if [ "$PG_VERSION" = "latest" ]; then
|
||||||
|
echo Testing SQLite and PostgreSQL under .NET $NET_VERSION...
|
||||||
|
dotnet run -f net$NET_VERSION
|
||||||
|
else
|
||||||
|
echo Testing PostgreSQL v$PG_VERSION under .NET $NET_VERSION...
|
||||||
|
BBDOX_PG_ONLY="true" dotnet run -f net$NET_VERSION
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
docker stop pg_test
|
||||||
|
sleep 2
|
||||||
|
docker rm pg_test
|
||||||
|
done
|
||||||
|
|
||||||
|
cd .. || exit
|
||||||
Reference in New Issue
Block a user