diff --git a/FsSql.Tests/FsSql.Tests.fsproj b/FsSql.Tests/FsSql.Tests.fsproj
index 3dfb15d..4b33696 100644
--- a/FsSql.Tests/FsSql.Tests.fsproj
+++ b/FsSql.Tests/FsSql.Tests.fsproj
@@ -1,57 +1,10 @@
-
-
+
+
- Debug
- AnyCPU
- {FFAE1F80-4C7C-4F58-9077-838C4265EED6}
Exe
- FsSql.Tests
- FsSql.Tests
- v4.5
- FsSql.Tests
-
- ..\
- true
+ net461
-
- true
- full
- false
- false
- bin\Debug\
- DEBUG;TRACE
- 3
- bin\Debug\FsSql.Tests.XML
- x86
-
-
- pdbonly
- true
- true
- bin\Release\
- TRACE
- 3
- bin\Release\FsSql.Tests.XML
-
-
- $(DefineConstants);__MonoSQL__
-
-
- 11
-
-
-
-
- $(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets
-
-
-
-
- $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets
-
-
-
-
+
@@ -59,33 +12,23 @@
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
-
- ..\packages\Fuchu.0.4.0.0\lib\Fuchu.dll
-
-
-
-
-
- ..\lib\System.Data.SQLite.dll
-
-
-
- FsSql
- {F2570DA4-5DF1-4D5E-9534-B3F55606B3B5}
-
-
-
- ..\packages\FSharpx.Collections.1.9.4\lib\net35\FSharpx.Collections.dll
-
-
- ..\packages\FSharp.Collections.ParallelSeq.1.0.2\lib\net40\FSharp.Collections.ParallelSeq.dll
-
-
- ..\packages\FSharp.Core.3.1.2.1\lib\net40\FSharp.Core.dll
-
+
+
-
\ No newline at end of file
+
+
diff --git a/FsSql.Tests/Tests.fs b/FsSql.Tests/Tests.fs
index e860969..2acb4c4 100644
--- a/FsSql.Tests/Tests.fs
+++ b/FsSql.Tests/Tests.fs
@@ -1,10 +1,20 @@
module FsSql.Tests.FsSqlTests
-open Fuchu
+open Expecto
+open Expect
open System
open System.Collections.Generic
open System.Data
+module Assert =
+ let Equal(msg, expected, actual) = equal actual expected msg
+ let None(msg, x) = if Option.isSome x then failtest msg
+ let Raise(msg, ty, f) =
+ function
+ | ex when ex.GetType() = ty -> ()
+ | ex -> failtest msg
+ |> throwsC f
+
#if __MonoSQL__
open Mono.Data.Sqlite
type SQLiteConnection = SqliteConnection
@@ -245,7 +255,8 @@ let dataReaderToSeqIsForwardOnly conn =
all |> Seq.truncate 10 |> Seq.iter (fun r -> logf "id: %d\n" (r?id).Value)
let secondIter() =
all |> Seq.truncate 10 |> Seq.iter (fun r -> logf "name: %s\n" (r?name).Value)
- Assert.Raise("invalid operation", typeof, secondIter)
+ //Assert.Raise("invalid operation", typeof, secondIter)
+ Assert.Raise("invalid operation", typeof, secondIter)
let dataReaderToSeqIsCacheable conn =
insertUsers conn |> ignore
@@ -485,139 +496,207 @@ let ``compose tx`` () =
| x -> failtestf "expected tx failure, was %A" x
Assert.Equal("user count", 0L, countUsers c)
-let ``tx monad error`` () =
- let c = withMemDb()
- let v = ref false
- let tran = tx {
- let! x = Tx.execNonQuery "select" []
- v := true
- return 3
- }
- let result = tran c // execute transaction
- match result with
- | Tx.Failed e ->
- Assert.Equal("executed", false, !v)
- logf "Error: %A\n" e
- | _ -> failtest "Transaction should have failed"
-
let txInsert id =
Tx.execNonQueryi "insert into person (id,name) values (@id, @name)" [P("@id",id);P("@name", "juan")]
-let ``tx monad error rollback`` () =
- let c = withMemDb()
- let tran = tx {
- let! x = Tx.execNonQuery "insert into person (id,name) values (@id, @name)" [P("@id",3);P("@name", "juan")]
- let! x = Tx.execNonQuery "select" []
- return ()
- }
- let result = tran c // execute transaction
- match result with
- | Tx.Failed e ->
- logf "Error: %A\n" e
- Assert.Equal("user count", 0L, countUsers c)
- | _ -> failtest "Transaction should have failed"
-
-let ``tx monad ok`` () =
- let c = withMemDb()
- let tran = tx {
- do! txInsert 3
- do! txInsert 4
- return 8
- }
- let result = tran c // execute transaction
- match result with
- | Tx.Commit a -> Assert.Equal("transaction result", 8, a)
- | Tx.Failed e -> failtest "Transaction should not have failed"
- | Tx.Rollback e -> failtest "Transaction should not have failed"
- Assert.Equal("user count", 2L, countUsers c)
-
-let ``tx monad using`` () =
- let c = withMemDb()
- let tran = tx {
- do! txInsert 3
- use! reader = Tx.execReader "select * from person" []
- let id =
- reader
- |> Seq.ofDataReader
- |> Seq.map (Sql.readField "id" >> Option.get)
- |> Enumerable.First
- return id
- }
- let result = tran c
- match result with
- | Tx.Commit a -> Assert.Equal("transaction result", 3, a)
- | Tx.Rollback a -> failtest "Transaction should not have failed"
- | Tx.Failed e -> failtest "Transaction should not have failed"
-
-let ``tx monad rollback and zero`` () =
- let c = withMemDb()
- let tran = tx {
- do! txInsert 3
- if 1 = 1
- then do! Tx.rollback 4
- return 0
- }
- let result = tran c
- match result with
- | Tx.Rollback a ->
- Assert.Equal("rollback result", 4, a)
- Assert.Equal("user count", 0L, countUsers c)
- | _ -> failtest "Transaction should have been rolled back"
-
-let ``tx monad tryfinally`` () =
- let c = withMemDb()
- let finallyRun = ref false
- let tran = tx {
- try
- do! txInsert 3
- failwith "Error!"
- finally
- finallyRun := true
- }
- let result = tran c
- match result with
- | Tx.Failed e ->
- Assert.Equal("fail message", "Error!", e.Message)
- Assert.Equal("finally run", true, !finallyRun)
- | _ -> failtest "Transaction should have failed"
-
-let ``tx monad composable`` () =
- let c = withMemDb()
- let tran1 = tx {
- do! txInsert 3
- }
- let tran = tx {
- do! tran1
- do! txInsert 4
- }
- let result = tran c
- match result with
- | Tx.Commit a -> Assert.Equal("user count", 2L, countUsers c)
- | Tx.Rollback a -> failtest "Transaction should not have failed"
- | Tx.Failed e -> failtest "Transaction should not have failed"
-
-let ``tx monad for`` () =
- let c = withMemDb()
- let tran = tx {
- for i in 1..50 do
- do! txInsert i
- }
- let result = tran c
- match result with
- | Tx.Commit a -> Assert.Equal("user count", 50L, countUsers c)
- | Tx.Rollback a -> failtest "Transaction should not have failed"
- | Tx.Failed e -> failtest "Transaction should not have failed"
-
-let ``tx monad for with error`` () =
- let c = withMemDb()
- let tran = tx {
- for i in 1..50 do
- do! txInsert 1
- }
- let result = tran c
- match result with
- | Tx.Failed e -> Assert.Equal("user count", 0L, countUsers c)
- | _ -> failtest "Transaction should have failed"
+let otherParallelizableTests =
+ testList "otherParallelizableTests" [
+ test "tx then no tx" {
+ let c = withMemDb()
+ txInsert 1 c |> ignore
+ let l = Sql.execReader c "select * from person" [] |> List.ofDataReader
+ Assert.Equal("result count", 1, l.Length)
+ }
+
+ test "tx monad trywith" {
+ let c = withMemDb()
+ let tran = tx {
+ try
+ do! txInsert 1
+ failwith "bye"
+ do! txInsert 2
+ with e ->
+ do! txInsert 3
+ }
+ let result = tran c
+ match result with
+ | Tx.Commit a -> Assert.Equal("user count", 2L, countUsers c)
+ | Tx.Rollback a -> failtest "Transaction should not have failed"
+ | Tx.Failed e -> failtest "Transaction should not have failed"
+ }
+
+ test "tx monad for" {
+ let c = withMemDb()
+ let tran = tx {
+ for i in 1..50 do
+ do! txInsert i
+ }
+ let result = tran c
+ match result with
+ | Tx.Commit a -> Assert.Equal("user count", 50L, countUsers c)
+ | Tx.Rollback a -> failtest "Transaction should not have failed"
+ | Tx.Failed e -> failtest "Transaction should not have failed"
+ }
+
+ test "tx monad for with error" {
+ let c = withMemDb()
+ let tran = tx {
+ for i in 1..50 do
+ do! txInsert 1
+ }
+ let result = tran c
+ match result with
+ | Tx.Failed e -> Assert.Equal("user count", 0L, countUsers c)
+ | _ -> failtest "Transaction should have failed"
+ }
+
+ test "tx monad composable" {
+ let c = withMemDb()
+ let tran1 = tx {
+ do! txInsert 3
+ }
+ let tran = tx {
+ do! tran1
+ do! txInsert 4
+ }
+ let result = tran c
+ match result with
+ | Tx.Commit a -> Assert.Equal("user count", 2L, countUsers c)
+ | Tx.Rollback a -> failtest "Transaction should not have failed"
+ | Tx.Failed e -> failtest "Transaction should not have failed"
+ }
+
+ test "tx monad error" {
+ let c = withMemDb()
+ let v = ref false
+ let tran = tx {
+ let! x = Tx.execNonQuery "select" []
+ v := true
+ return 3
+ }
+ let result = tran c // execute transaction
+ match result with
+ | Tx.Failed e ->
+ Assert.Equal("executed", false, !v)
+ logf "Error: %A\n" e
+ | _ -> failtest "Transaction should have failed"
+ }
+
+ test "tx monad error rollback" {
+ let c = withMemDb()
+ let tran = tx {
+ let! x = Tx.execNonQuery "insert into person (id,name) values (@id, @name)" [P("@id",3);P("@name", "juan")]
+ let! x = Tx.execNonQuery "select" []
+ return ()
+ }
+ let result = tran c // execute transaction
+ match result with
+ | Tx.Failed e ->
+ logf "Error: %A\n" e
+ Assert.Equal("user count", 0L, countUsers c)
+ | _ -> failtest "Transaction should have failed"
+ }
+
+ test "tx monad ok" {
+ let c = withMemDb()
+ let tran = tx {
+ do! txInsert 3
+ do! txInsert 4
+ return 8
+ }
+ let result = tran c // execute transaction
+ match result with
+ | Tx.Commit a -> Assert.Equal("transaction result", 8, a)
+ | Tx.Failed e -> failtest "Transaction should not have failed"
+ | Tx.Rollback e -> failtest "Transaction should not have failed"
+ Assert.Equal("user count", 2L, countUsers c)
+ }
+
+ test "tx monad using" {
+ let c = withMemDb()
+ let tran = tx {
+ do! txInsert 3
+ use! reader = Tx.execReader "select * from person" []
+ let id =
+ reader
+ |> Seq.ofDataReader
+ |> Seq.map (Sql.readField "id" >> Option.get)
+ |> Enumerable.First
+ return id
+ }
+ let result = tran c
+ match result with
+ | Tx.Commit a -> Assert.Equal("transaction result", 3, a)
+ | Tx.Rollback a -> failtest "Transaction should not have failed"
+ | Tx.Failed e -> failtest "Transaction should not have failed"
+ }
+
+ test "tx monad rollback and zero" {
+ let c = withMemDb()
+ let tran = tx {
+ do! txInsert 3
+ if 1 = 1
+ then do! Tx.rollback 4
+ return 0
+ }
+ let result = tran c
+ match result with
+ | Tx.Rollback a ->
+ Assert.Equal("rollback result", 4, a)
+ Assert.Equal("user count", 0L, countUsers c)
+ | _ -> failtest "Transaction should have been rolled back"
+ }
+
+ test "tx monad tryfinally" {
+ let c = withMemDb()
+ let finallyRun = ref false
+ let tran = tx {
+ try
+ do! txInsert 3
+ failwith "Error!"
+ finally
+ finallyRun := true
+ }
+ let result = tran c
+ match result with
+ | Tx.Failed e ->
+ Assert.Equal("fail message", "Error!", e.Message)
+ Assert.Equal("finally run", true, !finallyRun)
+ | _ -> failtest "Transaction should have failed"
+ }
+
+ test "can execute serialisable tx" {
+ let cm = withMemDb()
+ let select_one m = Sql.execScalar m "select 1" []
+ let select_one =
+ select_one |> Tx.transactionalWithIsolation IsolationLevel.Serializable
+ let res = select_one cm
+ Assert.Equal("Can execute tx", Tx.TxResult.Commit(Some 1L), res)
+ }
+
+ test "can execute serialisable tx 2" {
+ let tx = Tx.TransactionBuilder(IsolationLevel.Serializable)
+ let cm = withMemDb()
+ let select_one = tx {
+ logf "executing 1"
+ let! a = Tx.execScalar "select 1" []
+ let a : int64 = Option.get a
+ logf "rolling back"
+ do! Tx.rollback 3L
+ logf "executing 2"
+ let! b = Tx.execScalar "select 1" []
+ let b : int64 = Option.get b
+ return a + b
+ }
+ let res = select_one cm
+ Assert.Equal("Can execute tx", Tx.TxResult.Rollback 3L, res)
+ }
+
+ testCase "map to pair" ``map to pair``
+ testCase "map single field as option" ``map single field as option``
+ testCase "map single field" ``map single field``
+ testCase "asRecord throws with non-record type" ``asRecord throws with non-record type``
+ ]
(*
let ``tx monad while`` () =
@@ -636,53 +715,6 @@ let ``tx monad while`` () =
| Tx.Failed e -> failwithe e "Transaction should not have failed"
*)
-let ``tx monad trywith``() =
- let c = withMemDb()
- let tran = tx {
- try
- do! txInsert 1
- failwith "bye"
- do! txInsert 2
- with e ->
- do! txInsert 3
- }
- let result = tran c
- match result with
- | Tx.Commit a -> Assert.Equal("user count", 2L, countUsers c)
- | Tx.Rollback a -> failtest "Transaction should not have failed"
- | Tx.Failed e -> failtest "Transaction should not have failed"
-
-let ``tx then no tx``() =
- let c = withMemDb()
- txInsert 1 c |> ignore
- let l = Sql.execReader c "select * from person" [] |> List.ofDataReader
- Assert.Equal("result count", 1, l.Length)
-
-let ``can execute serialisable tx``() =
- let cm = withMemDb()
- let select_one m = Sql.execScalar m "select 1" []
- let select_one =
- select_one |> Tx.transactionalWithIsolation IsolationLevel.Serializable
- let res = select_one cm
- Assert.Equal("Can execute tx", Tx.TxResult.Commit(Some 1L), res)
-
-let ``can execute serialisable tx 2``() =
- let tx = Tx.TransactionBuilder(IsolationLevel.Serializable)
- let cm = withMemDb()
- let select_one = tx {
- logf "executing 1"
- let! a = Tx.execScalar "select 1" []
- let a : int64 = Option.get a
- logf "rolling back"
- do! Tx.rollback 3L
- logf "executing 2"
- let! b = Tx.execScalar "select 1" []
- let b : int64 = Option.get b
- return a + b
- }
- let res = select_one cm
- Assert.Equal("Can execute tx", Tx.TxResult.Rollback 3L, res)
-
// define test cases
let connMgrTests =
@@ -732,12 +764,8 @@ let connMgrTests =
match nested inner mgr with
| Tx.Commit _ -> ()
| other -> failtestf "Expected commit, got %A" other
-
-
]
-open Fuchu
-
let genTests conn suffix =
[ for name, test in connMgrTests ->
testCase (name + " " + suffix) (fun () -> conn() |> test) ]
@@ -745,41 +773,20 @@ let genTests conn suffix =
let persistentDBTests = genTests withNewDbFile "(file db)"
let memDBTests = genTests withMemDb "(memory db)"
-let otherParallelizableTests =
- [
- "tx then no tx", ``tx then no tx``
- "tx monad trywith", ``tx monad trywith``
- "tx monad for with error", ``tx monad for with error``
- "tx monad for", ``tx monad for``
- "tx monad composable", ``tx monad composable``
- "tx monad tryfinally", ``tx monad tryfinally``
- "tx monad rollback and zero", ``tx monad rollback and zero``
- "tx monad using", ``tx monad using``
- "tx monad ok", ``tx monad ok``
- "tx monad error rollback", ``tx monad error rollback``
- "tx monad error", ``tx monad error``
- "map to pair", ``map to pair``
- "map single field as option", ``map single field as option``
- "map single field", ``map single field``
- "asRecord throws with non-record type", ``asRecord throws with non-record type``
- "can execute serialisable tx", ``can execute serialisable tx``
- "can execute serialisable tx 2", ``can execute serialisable tx 2``
- ] |> List.map (fun (name, f) -> Fuchu.Tests.testCase name f)
-
-let nonParallelizableTests =
- [
- ``compose tx``
- ``map to triple``
- ``map asRecord with prefix with more fields``
- ``map asRecord with prefix``
- ``map asRecord with too few fields throws``
- ``map asRecord with different field order``
- ``map asRecord``
- ``list of map``
- ``left join``
- ``inner join``
- ``duplicate field names are NOT supported``
- ``async exec reader``
- ``create command``
- ] |> List.map TestCase
+let nonParallelizableTests =
+ testList "nonParallelizableTests" [
+ testCase "compose tx" ``compose tx``
+ testCase "map to triple" ``map to triple``
+ testCase "map asRecord with prefix with more fields" ``map asRecord with prefix with more fields``
+ testCase "map asRecord with prefix" ``map asRecord with prefix``
+ testCase "map asRecord with too few fields throws" ``map asRecord with too few fields throws``
+ testCase "map asRecord with different field order" ``map asRecord with different field order``
+ testCase "map asRecord" ``map asRecord``
+ testCase "list of map" ``list of map``
+ testCase "left join" ``left join``
+ testCase "inner join" ``inner join``
+ testCase "duplicate field names are NOT supported" ``duplicate field names are NOT supported``
+ testCase "async exec reader" ``async exec reader``
+ testCase "create command" ``create command``
+ ]
diff --git a/FsSql.Tests/main.fs b/FsSql.Tests/main.fs
index 33777c7..b645578 100644
--- a/FsSql.Tests/main.fs
+++ b/FsSql.Tests/main.fs
@@ -1,15 +1,13 @@
open System
open FsSql.Tests
open FsSql.Tests.FsSqlTests
-open Fuchu
-open Fuchu.Impl
+open Expecto
-let runTests() =
- let r1 = TestList (nonParallelizableTests @ persistentDBTests) |> evalSeq |> sumTestResults
- let r2 = TestList (otherParallelizableTests @ memDBTests) |> evalPar |> sumTestResults
- let r = r1 + r2
- Console.WriteLine r
- TestResultCounts.errorCode r
+let runTests() =
+ let t1 = testList "Sequenced" (nonParallelizableTests::persistentDBTests) |> testSequenced
+ let t2 = testList "Parallel" (otherParallelizableTests::memDBTests)
+ let t = testList "All" [t1;t2]
+ runTests defaultConfig t
let runAdventureWorks() =
AdventureWorksTests.select()
diff --git a/FsSql.Tests/packages.config b/FsSql.Tests/packages.config
deleted file mode 100644
index 78d0133..0000000
--- a/FsSql.Tests/packages.config
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/FsSql.Tests/prelude.fs b/FsSql.Tests/prelude.fs
index 2615988..221ce14 100644
--- a/FsSql.Tests/prelude.fs
+++ b/FsSql.Tests/prelude.fs
@@ -3,7 +3,6 @@
[]
module TestPrelude =
- open Fuchu
open System
let failwithe (e: #exn) msg = raise <| System.Exception(msg, e)
diff --git a/FsSql/AsyncExtensions.fs b/FsSql/AsyncExtensions.fs
index 5380062..f71bbf9 100644
--- a/FsSql/AsyncExtensions.fs
+++ b/FsSql/AsyncExtensions.fs
@@ -4,44 +4,26 @@ open System
open System.Collections.Generic
open System.Data
open System.Data.SqlClient
+open System.Threading
+open System.Threading.Tasks
open System.Xml
type SqlCommand with
- member cmd.AsyncExecNonQuery() =
- let abegin (a,b) = cmd.BeginExecuteNonQuery(a,b)
- let aend = cmd.EndExecuteNonQuery
- let acancel = cmd.Cancel
- Async.FromBeginEnd(abegin, aend, acancel)
-
- member cmd.AsyncExecReader() =
- let abegin (a,b) = cmd.BeginExecuteReader(a,b)
- let aend = cmd.EndExecuteReader
- let acancel = cmd.Cancel
- Async.FromBeginEnd(abegin, aend, acancel)
-
- member cmd.AsyncExecXmlReader() =
- let abegin (a,b) = cmd.BeginExecuteXmlReader(a,b)
- let aend = cmd.EndExecuteXmlReader
- let acancel = cmd.Cancel
- Async.FromBeginEnd(abegin, aend, acancel)
-
-let inline asyncExecNonQuery cmd =
- let abegin (a,b:obj)= (^a: (member BeginExecuteNonQuery: AsyncCallback*obj -> IAsyncResult) (cmd,a,b))
- let aend a = (^a: (member EndExecuteNonQuery: IAsyncResult -> int) (cmd,a))
- let acancel () = (^a: (member Cancel: unit -> unit) (cmd))
- Async.FromBeginEnd(abegin, aend, acancel)
-
-let inline asyncExecReader cmd =
- let abegin (a,b:obj)= (^a: (member BeginExecuteReader: AsyncCallback*obj -> IAsyncResult) (cmd,a,b))
- let aend a = (^a: (member EndExecuteReader: IAsyncResult -> #IDataReader) (cmd,a))
- let acancel () = (^a: (member Cancel: unit -> unit) (cmd))
- Async.FromBeginEnd(abegin, aend, acancel)
-
-let inline asyncExecXmlReader cmd =
- let abegin (a,b:obj)= (^a: (member BeginExecuteXmlReader: AsyncCallback*obj -> IAsyncResult) (cmd,a,b))
- let aend a = (^a: (member EndExecuteXmlReader: IAsyncResult -> XmlReader) (cmd,a))
- let acancel () = (^a: (member Cancel: unit -> unit) (cmd))
- Async.FromBeginEnd(abegin, aend, acancel)
+ member cmd.AsyncExecNonQuery(?cancellationToken) =
+ match cancellationToken with
+ | Some ct -> async { return! cmd.ExecuteNonQueryAsync(ct) |> Async.AwaitTask }
+ | None -> async { return! cmd.ExecuteNonQueryAsync() |> Async.AwaitTask }
+
+
+ member cmd.AsyncExecReader(?cancellationToken:CancellationToken) : SqlDataReader Async =
+ match cancellationToken with
+ | Some ct -> async { return! cmd.ExecuteReaderAsync(ct) |> Async.AwaitTask }
+ | None -> async { return! cmd.ExecuteReaderAsync() |> Async.AwaitTask }
+
+ member cmd.AsyncExecXmlReader(?cancellationToken) =
+ match cancellationToken with
+ | Some ct -> async { return! cmd.ExecuteXmlReaderAsync(ct) |> Async.AwaitTask }
+ | None -> async { return! cmd.ExecuteXmlReaderAsync() |> Async.AwaitTask }
type IAsyncOps =
abstract execNonQuery: IDbCommand -> int Async
@@ -51,10 +33,10 @@ let AsyncOpsRegistry = Dictionary()
let SqlClientAsyncOps =
{ new IAsyncOps with
- member x.execNonQuery cmd = asyncExecNonQuery (cmd :?> SqlCommand)
+ member x.execNonQuery cmd = (cmd :?> SqlCommand).AsyncExecNonQuery()
member x.execReader cmd =
async {
- let! r = asyncExecReader (cmd :?> SqlCommand)
+ let! r = (cmd :?> SqlCommand).AsyncExecReader()
return upcast r
} }
diff --git a/FsSql/FSharpTypeExtensions.fs b/FsSql/FSharpTypeExtensions.fs
index 16c2f65..33c4975 100644
--- a/FsSql/FSharpTypeExtensions.fs
+++ b/FsSql/FSharpTypeExtensions.fs
@@ -5,7 +5,6 @@ open System.Reflection
open Microsoft.FSharp.Reflection
open Microsoft.FSharp.Core
-[]
module FSharpType =
/// Returns true if type is an Option type
let IsOption (t: Type) =
@@ -25,6 +24,4 @@ module FSharpType =
let tryGetMethod (name: string) (types: Type[]) (t: Type) =
let m = t.GetMethod(name, types)
- if m = null
- then None
- else Some m
\ No newline at end of file
+ Option.ofObj m
diff --git a/FsSql/FSharpValueExtensions.fs b/FsSql/FSharpValueExtensions.fs
index 8fcd698..b359031 100644
--- a/FsSql/FSharpValueExtensions.fs
+++ b/FsSql/FSharpValueExtensions.fs
@@ -4,7 +4,6 @@ open System
open System.Reflection
open Microsoft.FSharp.Reflection
-[]
module FSharpValue =
///
/// Creates a None option for type
diff --git a/FsSql/FsSql.fs b/FsSql/FsSql.fs
index cfec525..79c6c5b 100644
--- a/FsSql/FsSql.fs
+++ b/FsSql/FsSql.fs
@@ -1,4 +1,3 @@
-[]
module Sql
open System
@@ -78,7 +77,6 @@ let internal PrintfFormatProc (worker: string * obj list -> 'd) (query: PrintfF
| x::xs -> FSharpType.MakeFunctionType(x,makeFunctionType xs)
| _ -> failwith "shouldn't happen"
let rec proc (types: Type list) (values: obj list) (a: obj) : obj =
- let id = Guid.NewGuid().ToString()
let values = a::values
match types with
| [x;y] ->
@@ -320,8 +318,8 @@ let mapOne mapper datareader =
/// Maps a row as a sequence of name,value
let asNameValue (r: IDataRecord) =
- let names = {0..r.FieldCount-1} |> Seq.map r.GetName
- let values = {0..r.FieldCount-1} |> Seq.map r.GetValue
+ let names = Seq.init r.FieldCount r.GetName
+ let values = Seq.init r.FieldCount r.GetValue
Seq.zip names values
/// Maps a row as a Map of name,value
diff --git a/FsSql/FsSql.fsproj b/FsSql/FsSql.fsproj
index 8a758cb..e3522e0 100644
--- a/FsSql/FsSql.fsproj
+++ b/FsSql/FsSql.fsproj
@@ -1,52 +1,9 @@
-
-
+
+
- Debug
- AnyCPU
- {F2570DA4-5DF1-4D5E-9534-B3F55606B3B5}
- Library
- FsSql
- v4.0
- FsSql
- FsSql
-
- ..\
+ netstandard2.0
-
- true
- full
- false
- false
- bin\$(TargetFrameworkVersion)\Debug\
- DEBUG;TRACE
- 3
- bin\$(TargetFrameworkVersion)\Debug\FsSql.XML
-
-
- pdbonly
- true
- true
- bin\$(TargetFrameworkVersion)\Release\
- TRACE
- 3
- bin\$(TargetFrameworkVersion)\Release\FsSql.XML
-
-
- 11
-
-
-
-
- $(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets
-
-
-
-
- $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets
-
-
-
-
+
@@ -66,20 +23,13 @@
+
-
-
-
-
-
-
- ..\packages\FSharp.Core.3.1.2.1\lib\net40\FSharp.Core.dll
-
-
- True
-
+
+
-
+
-
\ No newline at end of file
+
+
diff --git a/FsSql/Logging.fs b/FsSql/Logging.fs
index 195d4cb..33e9bd9 100644
--- a/FsSql/Logging.fs
+++ b/FsSql/Logging.fs
@@ -62,7 +62,7 @@ type LogLevel =
| 4 -> Warn
| 5 -> Error
| 6 -> Fatal
- | _ as i -> failwith "rank %i not available" i) i
+ | _ as i -> failwithf "rank %i not available" i) i
static member op_LessThan (a, b) = (a :> IComparable).CompareTo(b) < 0
static member op_LessThanOrEqual (a, b) = (a :> IComparable).CompareTo(b) <= 0
@@ -122,7 +122,6 @@ let private logger =
ref ((fun () -> DateTime.UtcNow.Ticks),
fun (name : string) -> NoopLogger)
-[]
module LogLine =
let mk (clock : unit -> Ticks) path level data message =
@@ -148,7 +147,6 @@ let configure (clock : unit -> Ticks) fLogger =
let getLoggerByName name =
(!logger |> snd) name
-[]
module Logger =
let log (logger : Logger) (line : LogLine) =
diff --git a/FsSql/packages.config b/FsSql/packages.config
deleted file mode 100644
index 21ad297..0000000
--- a/FsSql/packages.config
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
-
-
\ No newline at end of file
diff --git a/packages/repositories.config b/packages/repositories.config
deleted file mode 100644
index c7c1635..0000000
--- a/packages/repositories.config
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
-
-
\ No newline at end of file