Skip to content
This repository was archived by the owner on Jun 8, 2024. It is now read-only.

Commit 15e809b

Browse files
Version 2 (#5)
- BREAKING CHANGE: Remove ID column from database and most function calls - FEATURE: Support .NET 8
1 parent bb4799f commit 15e809b

17 files changed

Lines changed: 599 additions & 501 deletions

File tree

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717

1818
strategy:
1919
matrix:
20-
dotnet-version: [ "6.0", "7.0" ]
20+
dotnet-version: [ "6.0", "7.0", "8.0" ]
2121
postgres-version: [ "12", "13", "14", "15", "latest" ]
2222

2323
services:
@@ -53,7 +53,7 @@ jobs:
5353
- name: Setup .NET
5454
uses: actions/setup-dotnet@v3
5555
with:
56-
dotnet-version: "7.0"
56+
dotnet-version: "8.0"
5757
- name: Package F# Library
5858
run: dotnet pack src/$FS_PROJECT/$FS_PROJECT.fsproj -c Release
5959
- name: Move F# package

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,3 +349,6 @@ MigrationBackup/
349349
# Ionide (cross platform F# VS Code tools) working folder
350350
.ionide/
351351
.vscode/
352+
353+
# JetBrains
354+
.idea/

src/BitBadger.Npgsql.Documents.Tests/CSharpTests.fs

Lines changed: 165 additions & 179 deletions
Large diffs are not rendered by default.

src/BitBadger.Npgsql.Documents.Tests/Db.fs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,21 +50,26 @@ let connStr =
5050

5151
/// Create a data source using the derived connection string
5252
let mkDataSource cStr =
53-
(NpgsqlDataSourceBuilder cStr).Build ()
53+
NpgsqlDataSourceBuilder(cStr).Build()
5454

5555

5656
open BitBadger.Npgsql.FSharp.Documents
5757

5858
/// Build the throwaway database
5959
let buildDatabase () =
6060

61-
let database = ThrowawayDatabase.Create(connStr)
61+
let database = ThrowawayDatabase.Create connStr
6262

63-
database.ConnectionString
64-
|> Sql.connect
63+
let sqlProps = Sql.connect database.ConnectionString
64+
65+
sqlProps
6566
|> Sql.query (Definition.createTable tableName)
6667
|> Sql.executeNonQuery
6768
|> ignore
69+
sqlProps
70+
|> Sql.query (Definition.createKey tableName)
71+
|> Sql.executeNonQuery
72+
|> ignore
6873

6974
Configuration.useDataSource (mkDataSource database.ConnectionString)
7075

src/BitBadger.Npgsql.Documents.Tests/FSharpTests.fs

Lines changed: 77 additions & 93 deletions
Large diffs are not rendered by default.

src/BitBadger.Npgsql.Documents.sln

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "BitBadger.Npgsql.Documents.
99
EndProject
1010
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "BitBadger.Npgsql.Documents", "BitBadger.Npgsql.Documents\BitBadger.Npgsql.Documents.fsproj", "{D6FEDBB8-D20D-4D14-AEC8-5CA2EA32EDB0}"
1111
EndProject
12+
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "MigrateToV2", "MigrateToV2\MigrateToV2.fsproj", "{B288C600-8081-496E-8A92-DB861273779E}"
13+
EndProject
1214
Global
1315
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1416
Debug|Any CPU = Debug|Any CPU
@@ -30,5 +32,9 @@ Global
3032
{D6FEDBB8-D20D-4D14-AEC8-5CA2EA32EDB0}.Debug|Any CPU.Build.0 = Debug|Any CPU
3133
{D6FEDBB8-D20D-4D14-AEC8-5CA2EA32EDB0}.Release|Any CPU.ActiveCfg = Release|Any CPU
3234
{D6FEDBB8-D20D-4D14-AEC8-5CA2EA32EDB0}.Release|Any CPU.Build.0 = Release|Any CPU
35+
{B288C600-8081-496E-8A92-DB861273779E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
36+
{B288C600-8081-496E-8A92-DB861273779E}.Debug|Any CPU.Build.0 = Debug|Any CPU
37+
{B288C600-8081-496E-8A92-DB861273779E}.Release|Any CPU.ActiveCfg = Release|Any CPU
38+
{B288C600-8081-496E-8A92-DB861273779E}.Release|Any CPU.Build.0 = Release|Any CPU
3339
EndGlobalSection
3440
EndGlobal

src/BitBadger.Npgsql.Documents/Configuration.fs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,25 @@ open Npgsql
55
open BitBadger.Npgsql.FSharp.Documents
66

77
/// Specify the serializer to use for document serialization/deserialization
8-
let UseSerializer (ser : IDocumentSerializer) =
8+
let UseSerializer(ser: IDocumentSerializer) =
99
Configuration.useSerializer ser
1010

1111
/// Retrieve the currently configured serializer
12-
let Serializer () =
12+
let Serializer() =
1313
Configuration.serializer ()
1414

1515
/// Register a data source to use for query execution (disposes the current one if it exists)
16-
let UseDataSource (source : NpgsqlDataSource) =
16+
let UseDataSource(source: NpgsqlDataSource) =
1717
Configuration.useDataSource source
1818

1919
/// Retrieve the currently configured data source
20-
let DataSource () =
20+
let DataSource() =
2121
Configuration.dataSource ()
22+
23+
/// Set the ID field name to use for documents
24+
let UseIdField(name: string) =
25+
Configuration.useIdField name
26+
27+
/// Retrieve the currently configured ID field name
28+
let IdField() =
29+
Configuration.idField ()

src/BitBadger.Npgsql.Documents/Definition.fs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module BitBadger.Npgsql.Documents.Definition
22

33
open Npgsql.FSharp
44

5-
/// Alias for F# document module
5+
// Alias for F# document module
66
module FS = BitBadger.Npgsql.FSharp.Documents
77

88
/// Convert the C# index type representation to the F# one
@@ -13,29 +13,31 @@ let private convertIndexType idxType =
1313
| it -> invalidOp $"Index type {it} invalid"
1414

1515
/// SQL statement to create a document table
16-
let CreateTable (name : string) =
16+
let CreateTable(name: string) =
1717
FS.Definition.createTable name
1818

19+
/// SQL statement to create a key index for a document table
20+
let CreateKey(name: string) =
21+
FS.Definition.createKey name
22+
1923
/// SQL statement to create an index on documents in the specified table
20-
let CreateIndex (name : string, idxType : DocumentIndex) =
24+
let CreateIndex(name: string, idxType: DocumentIndex) =
2125
FS.Definition.createIndex name (convertIndexType idxType)
2226

2327
/// Definitions that take SqlProps as their last parameter
2428
module WithProps =
2529

2630
/// Create a document table
27-
let EnsureTable (name : string, sqlProps : Sql.SqlProps) =
31+
let EnsureTable(name: string, sqlProps: Sql.SqlProps) =
2832
FS.Definition.WithProps.ensureTable name sqlProps
2933

3034
/// Create an index on documents in the specified table
31-
let EnsureIndex (name : string, idxType : DocumentIndex, sqlProps : Sql.SqlProps) =
35+
let EnsureIndex(name: string, idxType: DocumentIndex, sqlProps: Sql.SqlProps) =
3236
FS.Definition.WithProps.ensureIndex name (convertIndexType idxType) sqlProps
3337

3438
/// Create a document table
3539
let EnsureTable name =
36-
WithProps.EnsureTable (name, FS.fromDataSource ())
40+
WithProps.EnsureTable(name, FS.fromDataSource ())
3741

3842
let EnsureIndex (name, idxType) =
39-
WithProps.EnsureIndex (name, idxType, FS.fromDataSource ())
40-
41-
43+
WithProps.EnsureIndex(name, idxType, FS.fromDataSource ())

0 commit comments

Comments
 (0)