Skip to content

Commit

Permalink
feat(tc): add support for weird isolation level
Browse files Browse the repository at this point in the history
  • Loading branch information
Kerry Perret committed Jan 23, 2021
1 parent b9669bc commit 38a01c8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
11 changes: 5 additions & 6 deletions Vp.FSharp.Sql/Transaction.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ module Vp.FSharp.Sql.Transaction

open System.Threading
open System.Data.Common

open System.Threading.Tasks
open System.Transactions
open System.Threading.Tasks

open Vp.FSharp.Sql.Helpers

Expand All @@ -15,7 +14,7 @@ let DefaultIsolationLevel = IsolationLevel.ReadCommitted

let commit cancellationToken isolationLevel
(connection: #DbConnection)
(beginTransaction: #DbConnection -> IsolationLevel -> CancellationToken -> ValueTask<#DbTransaction>)
(beginTransaction: #DbConnection -> 'IsolationLevel -> CancellationToken -> ValueTask<#DbTransaction>)
(body: #DbConnection -> #DbTransaction -> Async<'Output>)=
async {
let wasClosed = DbConnection.isClosed connection
Expand All @@ -32,7 +31,7 @@ let commit cancellationToken isolationLevel

let notCommit cancellationToken isolationLevel
(connection: #DbConnection)
(beginTransaction: #DbConnection -> IsolationLevel -> CancellationToken -> ValueTask<#DbTransaction>)
(beginTransaction: #DbConnection -> 'IsolationLevel -> CancellationToken -> ValueTask<#DbTransaction>)
(body: #DbConnection -> #DbTransaction -> Async<'Output>) =
async {
let wasClosed = DbConnection.isClosed connection
Expand All @@ -48,7 +47,7 @@ let notCommit cancellationToken isolationLevel

let commitOnSome cancellationToken isolationLevel
(connection: #DbConnection)
(beginTransaction: #DbConnection -> IsolationLevel -> CancellationToken -> ValueTask<#DbTransaction>)
(beginTransaction: #DbConnection -> 'IsolationLevel -> CancellationToken -> ValueTask<#DbTransaction>)
(body: #DbConnection -> #DbTransaction -> Async<'Output option>) =
async {
let wasClosed = DbConnection.isClosed connection
Expand All @@ -68,7 +67,7 @@ let commitOnSome cancellationToken isolationLevel

let commitOnOk cancellationToken isolationLevel
(connection: #DbConnection)
(beginTransaction: #DbConnection -> IsolationLevel -> CancellationToken -> ValueTask<#DbTransaction>)
(beginTransaction: #DbConnection -> 'IsolationLevel -> CancellationToken -> ValueTask<#DbTransaction>)
(body: #DbConnection -> #DbTransaction -> Async<Result<'Ok, 'Error>>) =
async {
let wasClosed = DbConnection.isClosed connection
Expand Down
5 changes: 3 additions & 2 deletions Vp.FSharp.Sql/Types.fs
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,16 @@ type SqlConfigurationCache<'DbConnection, 'DbCommand

// Ie. The ADO.NET Provider generic constraints mapper due to the lack of proper support for some variant of the SRTP
// and the hideous members shadowing occuring in most ADO.NET Providers implementation
type SqlDependencies<'DbConnection, 'DbCommand, 'DbParameter, 'DbDataReader, 'DbTransaction, 'DbType
type SqlDependencies<'DbConnection, 'DbCommand, 'DbParameter, 'DbDataReader,
'DbTransaction, 'DbTransactionIsolationLevel, 'DbType
when 'DbConnection :> DbConnection
and 'DbCommand :> DbCommand
and 'DbParameter :> DbParameter
and 'DbDataReader :> DbDataReader
and 'DbTransaction :> DbTransaction> =
{ CreateCommand: 'DbConnection -> 'DbCommand
SetCommandTransaction: 'DbCommand -> 'DbTransaction -> unit
BeginTransactionAsync: 'DbConnection -> IsolationLevel -> CancellationToken -> ValueTask<'DbTransaction>
BeginTransactionAsync: 'DbConnection -> 'DbTransactionIsolationLevel -> CancellationToken -> ValueTask<'DbTransaction>
ExecuteReaderAsync: 'DbCommand -> CancellationToken -> Task<'DbDataReader>
DbValueToParameter: string -> 'DbType -> 'DbParameter }

Expand Down

0 comments on commit 38a01c8

Please sign in to comment.