RC4 changes (#7)
- Add `In` and `InArray` comparisons - Replace `Op` with `Comparison` (internal API, but was public) - Spell out comparisons in `Field` constructor functions Reviewed-on: #7
This commit was merged in pull request #7.
This commit is contained in:
@@ -7,170 +7,183 @@ open Expecto
|
||||
let tbl = "test_table"
|
||||
|
||||
/// Unit tests for the Op DU
|
||||
let opTests = testList "Op" [
|
||||
test "EQ succeeds" {
|
||||
Expect.equal (string EQ) "=" "The equals operator was not correct"
|
||||
let comparisonTests = testList "Comparison.OpSql" [
|
||||
test "Equal succeeds" {
|
||||
Expect.equal (Equal "").OpSql "=" "The Equals SQL was not correct"
|
||||
}
|
||||
test "GT succeeds" {
|
||||
Expect.equal (string GT) ">" "The greater than operator was not correct"
|
||||
test "Greater succeeds" {
|
||||
Expect.equal (Greater "").OpSql ">" "The Greater SQL was not correct"
|
||||
}
|
||||
test "GE succeeds" {
|
||||
Expect.equal (string GE) ">=" "The greater than or equal to operator was not correct"
|
||||
test "GreaterOrEqual succeeds" {
|
||||
Expect.equal (GreaterOrEqual "").OpSql ">=" "The GreaterOrEqual SQL was not correct"
|
||||
}
|
||||
test "LT succeeds" {
|
||||
Expect.equal (string LT) "<" "The less than operator was not correct"
|
||||
test "Less succeeds" {
|
||||
Expect.equal (Less "").OpSql "<" "The Less SQL was not correct"
|
||||
}
|
||||
test "LE succeeds" {
|
||||
Expect.equal (string LE) "<=" "The less than or equal to operator was not correct"
|
||||
test "LessOrEqual succeeds" {
|
||||
Expect.equal (LessOrEqual "").OpSql "<=" "The LessOrEqual SQL was not correct"
|
||||
}
|
||||
test "NE succeeds" {
|
||||
Expect.equal (string NE) "<>" "The not equal to operator was not correct"
|
||||
test "NotEqual succeeds" {
|
||||
Expect.equal (NotEqual "").OpSql "<>" "The NotEqual SQL was not correct"
|
||||
}
|
||||
test "BT succeeds" {
|
||||
Expect.equal (string BT) "BETWEEN" """The "between" operator was not correct"""
|
||||
test "Between succeeds" {
|
||||
Expect.equal (Between("", "")).OpSql "BETWEEN" "The Between SQL was not correct"
|
||||
}
|
||||
test "EX succeeds" {
|
||||
Expect.equal (string EX) "IS NOT NULL" """The "exists" operator was not correct"""
|
||||
test "In succeeds" {
|
||||
Expect.equal (In []).OpSql "IN" "The In SQL was not correct"
|
||||
}
|
||||
test "NEX succeeds" {
|
||||
Expect.equal (string NEX) "IS NULL" """The "not exists" operator was not correct"""
|
||||
test "InArray succeeds" {
|
||||
Expect.equal (InArray("", [])).OpSql "?|" "The InArray SQL was not correct"
|
||||
}
|
||||
test "Exists succeeds" {
|
||||
Expect.equal Exists.OpSql "IS NOT NULL" "The Exists SQL was not correct"
|
||||
}
|
||||
test "NotExists succeeds" {
|
||||
Expect.equal NotExists.OpSql "IS NULL" "The NotExists SQL was not correct"
|
||||
}
|
||||
]
|
||||
|
||||
/// Unit tests for the Field class
|
||||
let fieldTests = testList "Field" [
|
||||
test "EQ succeeds" {
|
||||
let field = Field.EQ "Test" 14
|
||||
test "Equal succeeds" {
|
||||
let field = Field.Equal "Test" 14
|
||||
Expect.equal field.Name "Test" "Field name incorrect"
|
||||
Expect.equal field.Op EQ "Operator incorrect"
|
||||
Expect.equal field.Value 14 "Value incorrect"
|
||||
Expect.equal field.Comparison (Equal 14) "Comparison incorrect"
|
||||
Expect.isNone field.ParameterName "The default parameter name should be None"
|
||||
Expect.isNone field.Qualifier "The default table qualifier should be None"
|
||||
}
|
||||
test "GT succeeds" {
|
||||
let field = Field.GT "Great" "night"
|
||||
test "Greater succeeds" {
|
||||
let field = Field.Greater "Great" "night"
|
||||
Expect.equal field.Name "Great" "Field name incorrect"
|
||||
Expect.equal field.Op GT "Operator incorrect"
|
||||
Expect.equal field.Value "night" "Value incorrect"
|
||||
Expect.equal field.Comparison (Greater "night") "Comparison incorrect"
|
||||
Expect.isNone field.ParameterName "The default parameter name should be None"
|
||||
Expect.isNone field.Qualifier "The default table qualifier should be None"
|
||||
}
|
||||
test "GE succeeds" {
|
||||
let field = Field.GE "Nice" 88L
|
||||
test "GreaterOrEqual succeeds" {
|
||||
let field = Field.GreaterOrEqual "Nice" 88L
|
||||
Expect.equal field.Name "Nice" "Field name incorrect"
|
||||
Expect.equal field.Op GE "Operator incorrect"
|
||||
Expect.equal field.Value 88L "Value incorrect"
|
||||
Expect.equal field.Comparison (GreaterOrEqual 88L) "Comparison incorrect"
|
||||
Expect.isNone field.ParameterName "The default parameter name should be None"
|
||||
Expect.isNone field.Qualifier "The default table qualifier should be None"
|
||||
}
|
||||
test "LT succeeds" {
|
||||
let field = Field.LT "Lesser" "seven"
|
||||
test "Less succeeds" {
|
||||
let field = Field.Less "Lesser" "seven"
|
||||
Expect.equal field.Name "Lesser" "Field name incorrect"
|
||||
Expect.equal field.Op LT "Operator incorrect"
|
||||
Expect.equal field.Value "seven" "Value incorrect"
|
||||
Expect.equal field.Comparison (Less "seven") "Comparison incorrect"
|
||||
Expect.isNone field.ParameterName "The default parameter name should be None"
|
||||
Expect.isNone field.Qualifier "The default table qualifier should be None"
|
||||
}
|
||||
test "LE succeeds" {
|
||||
let field = Field.LE "Nobody" "KNOWS";
|
||||
test "LessOrEqual succeeds" {
|
||||
let field = Field.LessOrEqual "Nobody" "KNOWS";
|
||||
Expect.equal field.Name "Nobody" "Field name incorrect"
|
||||
Expect.equal field.Op LE "Operator incorrect"
|
||||
Expect.equal field.Value "KNOWS" "Value incorrect"
|
||||
Expect.equal field.Comparison (LessOrEqual "KNOWS") "Comparison incorrect"
|
||||
Expect.isNone field.ParameterName "The default parameter name should be None"
|
||||
Expect.isNone field.Qualifier "The default table qualifier should be None"
|
||||
}
|
||||
test "NE succeeds" {
|
||||
let field = Field.NE "Park" "here"
|
||||
test "NotEqual succeeds" {
|
||||
let field = Field.NotEqual "Park" "here"
|
||||
Expect.equal field.Name "Park" "Field name incorrect"
|
||||
Expect.equal field.Op NE "Operator incorrect"
|
||||
Expect.equal field.Value "here" "Value incorrect"
|
||||
Expect.equal field.Comparison (NotEqual "here") "Comparison incorrect"
|
||||
Expect.isNone field.ParameterName "The default parameter name should be None"
|
||||
Expect.isNone field.Qualifier "The default table qualifier should be None"
|
||||
}
|
||||
test "BT succeeds" {
|
||||
let field = Field.BT "Age" 18 49
|
||||
test "Between succeeds" {
|
||||
let field = Field.Between "Age" 18 49
|
||||
Expect.equal field.Name "Age" "Field name incorrect"
|
||||
Expect.equal field.Op BT "Operator incorrect"
|
||||
Expect.sequenceEqual (field.Value :?> obj list) [ 18; 49 ] "Value incorrect"
|
||||
Expect.equal field.Comparison (Between(18, 49)) "Comparison incorrect"
|
||||
Expect.isNone field.ParameterName "The default parameter name should be None"
|
||||
Expect.isNone field.Qualifier "The default table qualifier should be None"
|
||||
}
|
||||
test "EX succeeds" {
|
||||
let field = Field.EX "Groovy"
|
||||
test "In succeeds" {
|
||||
let field = Field.In "Here" [| 8; 16; 32 |]
|
||||
Expect.equal field.Name "Here" "Field name incorrect"
|
||||
Expect.equal field.Comparison (In [| 8; 16; 32 |]) "Comparison incorrect"
|
||||
Expect.isNone field.ParameterName "The default parameter name should be None"
|
||||
Expect.isNone field.Qualifier "The default table qualifier should be None"
|
||||
}
|
||||
test "InArray succeeds" {
|
||||
let field = Field.InArray "ArrayField" "table" [| "z" |]
|
||||
Expect.equal field.Name "ArrayField" "Field name incorrect"
|
||||
Expect.equal field.Comparison (InArray("table", [| "z" |])) "Comparison incorrect"
|
||||
Expect.isNone field.ParameterName "The default parameter name should be None"
|
||||
Expect.isNone field.Qualifier "The default table qualifier should be None"
|
||||
}
|
||||
test "Exists succeeds" {
|
||||
let field = Field.Exists "Groovy"
|
||||
Expect.equal field.Name "Groovy" "Field name incorrect"
|
||||
Expect.equal field.Op EX "Operator incorrect"
|
||||
Expect.equal field.Comparison Exists "Comparison incorrect"
|
||||
Expect.isNone field.ParameterName "The default parameter name should be None"
|
||||
Expect.isNone field.Qualifier "The default table qualifier should be None"
|
||||
}
|
||||
test "NEX succeeds" {
|
||||
let field = Field.NEX "Rad"
|
||||
test "NotExists succeeds" {
|
||||
let field = Field.NotExists "Rad"
|
||||
Expect.equal field.Name "Rad" "Field name incorrect"
|
||||
Expect.equal field.Op NEX "Operator incorrect"
|
||||
Expect.equal field.Comparison NotExists "Comparison incorrect"
|
||||
Expect.isNone field.ParameterName "The default parameter name should be None"
|
||||
Expect.isNone field.Qualifier "The default table qualifier should be None"
|
||||
}
|
||||
testList "NameToPath" [
|
||||
test "succeeds for PostgreSQL and a simple name" {
|
||||
Expect.equal "data->>'Simple'" (Field.NameToPath "Simple" PostgreSQL) "Path not constructed correctly"
|
||||
Expect.equal "data->>'Simple'" (Field.NameToPath "Simple" PostgreSQL AsSql) "Path not constructed correctly"
|
||||
}
|
||||
test "succeeds for SQLite and a simple name" {
|
||||
Expect.equal "data->>'Simple'" (Field.NameToPath "Simple" SQLite) "Path not constructed correctly"
|
||||
Expect.equal "data->>'Simple'" (Field.NameToPath "Simple" SQLite AsSql) "Path not constructed correctly"
|
||||
}
|
||||
test "succeeds for PostgreSQL and a nested name" {
|
||||
Expect.equal
|
||||
"data#>>'{A,Long,Path,to,the,Property}'"
|
||||
(Field.NameToPath "A.Long.Path.to.the.Property" PostgreSQL)
|
||||
(Field.NameToPath "A.Long.Path.to.the.Property" PostgreSQL AsSql)
|
||||
"Path not constructed correctly"
|
||||
}
|
||||
test "succeeds for SQLite and a nested name" {
|
||||
Expect.equal
|
||||
"data->>'A'->>'Long'->>'Path'->>'to'->>'the'->>'Property'"
|
||||
(Field.NameToPath "A.Long.Path.to.the.Property" SQLite)
|
||||
"data->'A'->'Long'->'Path'->'to'->'the'->>'Property'"
|
||||
(Field.NameToPath "A.Long.Path.to.the.Property" SQLite AsSql)
|
||||
"Path not constructed correctly"
|
||||
}
|
||||
]
|
||||
test "WithParameterName succeeds" {
|
||||
let field = (Field.EQ "Bob" "Tom").WithParameterName "@name"
|
||||
let field = (Field.Equal "Bob" "Tom").WithParameterName "@name"
|
||||
Expect.isSome field.ParameterName "The parameter name should have been filled"
|
||||
Expect.equal "@name" field.ParameterName.Value "The parameter name is incorrect"
|
||||
}
|
||||
test "WithQualifier succeeds" {
|
||||
let field = (Field.EQ "Bill" "Matt").WithQualifier "joe"
|
||||
let field = (Field.Equal "Bill" "Matt").WithQualifier "joe"
|
||||
Expect.isSome field.Qualifier "The table qualifier should have been filled"
|
||||
Expect.equal "joe" field.Qualifier.Value "The table qualifier is incorrect"
|
||||
}
|
||||
testList "Path" [
|
||||
test "succeeds for a PostgreSQL single field with no qualifier" {
|
||||
let field = Field.GE "SomethingCool" 18
|
||||
Expect.equal "data->>'SomethingCool'" (field.Path PostgreSQL) "The PostgreSQL path is incorrect"
|
||||
let field = Field.GreaterOrEqual "SomethingCool" 18
|
||||
Expect.equal "data->>'SomethingCool'" (field.Path PostgreSQL AsSql) "The PostgreSQL path is incorrect"
|
||||
}
|
||||
test "succeeds for a PostgreSQL single field with a qualifier" {
|
||||
let field = { Field.LT "SomethingElse" 9 with Qualifier = Some "this" }
|
||||
Expect.equal "this.data->>'SomethingElse'" (field.Path PostgreSQL) "The PostgreSQL path is incorrect"
|
||||
let field = { Field.Less "SomethingElse" 9 with Qualifier = Some "this" }
|
||||
Expect.equal "this.data->>'SomethingElse'" (field.Path PostgreSQL AsSql) "The PostgreSQL path is incorrect"
|
||||
}
|
||||
test "succeeds for a PostgreSQL nested field with no qualifier" {
|
||||
let field = Field.EQ "My.Nested.Field" "howdy"
|
||||
Expect.equal "data#>>'{My,Nested,Field}'" (field.Path PostgreSQL) "The PostgreSQL path is incorrect"
|
||||
let field = Field.Equal "My.Nested.Field" "howdy"
|
||||
Expect.equal "data#>>'{My,Nested,Field}'" (field.Path PostgreSQL AsSql) "The PostgreSQL path is incorrect"
|
||||
}
|
||||
test "succeeds for a PostgreSQL nested field with a qualifier" {
|
||||
let field = { Field.EQ "Nest.Away" "doc" with Qualifier = Some "bird" }
|
||||
Expect.equal "bird.data#>>'{Nest,Away}'" (field.Path PostgreSQL) "The PostgreSQL path is incorrect"
|
||||
let field = { Field.Equal "Nest.Away" "doc" with Qualifier = Some "bird" }
|
||||
Expect.equal "bird.data#>>'{Nest,Away}'" (field.Path PostgreSQL AsSql) "The PostgreSQL path is incorrect"
|
||||
}
|
||||
test "succeeds for a SQLite single field with no qualifier" {
|
||||
let field = Field.GE "SomethingCool" 18
|
||||
Expect.equal "data->>'SomethingCool'" (field.Path SQLite) "The SQLite path is incorrect"
|
||||
let field = Field.GreaterOrEqual "SomethingCool" 18
|
||||
Expect.equal "data->>'SomethingCool'" (field.Path SQLite AsSql) "The SQLite path is incorrect"
|
||||
}
|
||||
test "succeeds for a SQLite single field with a qualifier" {
|
||||
let field = { Field.LT "SomethingElse" 9 with Qualifier = Some "this" }
|
||||
Expect.equal "this.data->>'SomethingElse'" (field.Path SQLite) "The SQLite path is incorrect"
|
||||
let field = { Field.Less "SomethingElse" 9 with Qualifier = Some "this" }
|
||||
Expect.equal "this.data->>'SomethingElse'" (field.Path SQLite AsSql) "The SQLite path is incorrect"
|
||||
}
|
||||
test "succeeds for a SQLite nested field with no qualifier" {
|
||||
let field = Field.EQ "My.Nested.Field" "howdy"
|
||||
Expect.equal "data->>'My'->>'Nested'->>'Field'" (field.Path SQLite) "The SQLite path is incorrect"
|
||||
let field = Field.Equal "My.Nested.Field" "howdy"
|
||||
Expect.equal "data->'My'->'Nested'->>'Field'" (field.Path SQLite AsSql) "The SQLite path is incorrect"
|
||||
}
|
||||
test "succeeds for a SQLite nested field with a qualifier" {
|
||||
let field = { Field.EQ "Nest.Away" "doc" with Qualifier = Some "bird" }
|
||||
Expect.equal "bird.data->>'Nest'->>'Away'" (field.Path SQLite) "The SQLite path is incorrect"
|
||||
let field = { Field.Equal "Nest.Away" "doc" with Qualifier = Some "bird" }
|
||||
Expect.equal "bird.data->'Nest'->>'Away'" (field.Path SQLite AsSql) "The SQLite path is incorrect"
|
||||
}
|
||||
]
|
||||
]
|
||||
@@ -373,7 +386,7 @@ let queryTests = testList "Query" [
|
||||
test "succeeds for nested SQLite field" {
|
||||
Expect.equal
|
||||
(Query.Definition.ensureIndexOn tbl "nest" [ "a.b.c" ] SQLite)
|
||||
$"CREATE INDEX IF NOT EXISTS idx_{tbl}_nest ON {tbl} ((data->>'a'->>'b'->>'c'))"
|
||||
$"CREATE INDEX IF NOT EXISTS idx_{tbl}_nest ON {tbl} ((data->'a'->'b'->>'c'))"
|
||||
"CREATE INDEX for nested SQLite field incorrect"
|
||||
}
|
||||
]
|
||||
@@ -435,7 +448,7 @@ let queryTests = testList "Query" [
|
||||
(Query.orderBy
|
||||
[ Field.Named "Nested.Test.Field DESC"; Field.Named "AnotherField"; Field.Named "It DESC" ]
|
||||
SQLite)
|
||||
" ORDER BY data->>'Nested'->>'Test'->>'Field' DESC, data->>'AnotherField', data->>'It' DESC"
|
||||
" ORDER BY data->'Nested'->'Test'->>'Field' DESC, data->>'AnotherField', data->>'It' DESC"
|
||||
"Order By not constructed correctly"
|
||||
}
|
||||
test "succeeds for PostgreSQL numeric fields" {
|
||||
@@ -459,7 +472,7 @@ let queryTests = testList "Query" [
|
||||
test "succeeds for SQLite case-insensitive ordering" {
|
||||
Expect.equal
|
||||
(Query.orderBy [ Field.Named "i:Test.Field ASC NULLS LAST" ] SQLite)
|
||||
" ORDER BY data->>'Test'->>'Field' COLLATE NOCASE ASC NULLS LAST"
|
||||
" ORDER BY data->'Test'->>'Field' COLLATE NOCASE ASC NULLS LAST"
|
||||
"Order By not constructed correctly for case-insensitive field"
|
||||
}
|
||||
]
|
||||
@@ -467,7 +480,7 @@ let queryTests = testList "Query" [
|
||||
|
||||
/// Tests which do not hit the database
|
||||
let all = testList "Common" [
|
||||
opTests
|
||||
comparisonTests
|
||||
fieldTests
|
||||
fieldMatchTests
|
||||
parameterNameTests
|
||||
|
||||
@@ -214,7 +214,7 @@ let integrationTests =
|
||||
use conn = mkConn db
|
||||
do! loadDocs conn
|
||||
|
||||
let! theCount = conn.countByFields PostgresDb.TableName Any [ Field.EQ "Value" "purple" ]
|
||||
let! theCount = conn.countByFields PostgresDb.TableName Any [ Field.Equal "Value" "purple" ]
|
||||
Expect.equal theCount 2 "There should have been 2 matching documents"
|
||||
}
|
||||
testTask "countByContains succeeds" {
|
||||
@@ -257,7 +257,7 @@ let integrationTests =
|
||||
use conn = mkConn db
|
||||
do! loadDocs conn
|
||||
|
||||
let! exists = conn.existsByFields PostgresDb.TableName Any [ Field.EX "Sub" ]
|
||||
let! exists = conn.existsByFields PostgresDb.TableName Any [ Field.Exists "Sub" ]
|
||||
Expect.isTrue exists "There should have been existing documents"
|
||||
}
|
||||
testTask "succeeds when documents do not exist" {
|
||||
@@ -265,7 +265,7 @@ let integrationTests =
|
||||
use conn = mkConn db
|
||||
do! loadDocs conn
|
||||
|
||||
let! exists = conn.existsByFields PostgresDb.TableName Any [ Field.EQ "NumValue" "six" ]
|
||||
let! exists = conn.existsByFields PostgresDb.TableName Any [ Field.Equal "NumValue" "six" ]
|
||||
Expect.isFalse exists "There should not have been existing documents"
|
||||
}
|
||||
]
|
||||
@@ -390,7 +390,7 @@ let integrationTests =
|
||||
use conn = mkConn db
|
||||
do! loadDocs conn
|
||||
|
||||
let! docs = conn.findByFields<JsonDocument> PostgresDb.TableName Any [ Field.EQ "Value" "another" ]
|
||||
let! docs = conn.findByFields<JsonDocument> PostgresDb.TableName Any [ Field.Equal "Value" "another" ]
|
||||
Expect.equal (List.length docs) 1 "There should have been one document returned"
|
||||
}
|
||||
testTask "succeeds when documents are not found" {
|
||||
@@ -398,7 +398,7 @@ let integrationTests =
|
||||
use conn = mkConn db
|
||||
do! loadDocs conn
|
||||
|
||||
let! docs = conn.findByFields<JsonDocument> PostgresDb.TableName Any [ Field.EQ "Value" "mauve" ]
|
||||
let! docs = conn.findByFields<JsonDocument> PostgresDb.TableName Any [ Field.Equal "Value" "mauve" ]
|
||||
Expect.isEmpty docs "There should have been no documents returned"
|
||||
}
|
||||
]
|
||||
@@ -410,7 +410,7 @@ let integrationTests =
|
||||
|
||||
let! docs =
|
||||
conn.findByFieldsOrdered<JsonDocument>
|
||||
PostgresDb.TableName All [ Field.EQ "Value" "purple" ] [ Field.Named "Id" ]
|
||||
PostgresDb.TableName All [ Field.Equal "Value" "purple" ] [ Field.Named "Id" ]
|
||||
Expect.hasLength docs 2 "There should have been two documents returned"
|
||||
Expect.equal
|
||||
(docs |> List.map _.Id |> String.concat "|") "five|four" "Documents not ordered correctly"
|
||||
@@ -422,7 +422,7 @@ let integrationTests =
|
||||
|
||||
let! docs =
|
||||
conn.findByFieldsOrdered<JsonDocument>
|
||||
PostgresDb.TableName All [ Field.EQ "Value" "purple" ] [ Field.Named "Id DESC" ]
|
||||
PostgresDb.TableName All [ Field.Equal "Value" "purple" ] [ Field.Named "Id DESC" ]
|
||||
Expect.hasLength docs 2 "There should have been two documents returned"
|
||||
Expect.equal
|
||||
(docs |> List.map _.Id |> String.concat "|") "four|five" "Documents not ordered correctly"
|
||||
@@ -524,7 +524,8 @@ let integrationTests =
|
||||
use conn = mkConn db
|
||||
do! loadDocs conn
|
||||
|
||||
let! doc = conn.findFirstByFields<JsonDocument> PostgresDb.TableName Any [ Field.EQ "Value" "another" ]
|
||||
let! doc =
|
||||
conn.findFirstByFields<JsonDocument> PostgresDb.TableName Any [ Field.Equal "Value" "another" ]
|
||||
Expect.isSome doc "There should have been a document returned"
|
||||
Expect.equal doc.Value.Id "two" "The incorrect document was returned"
|
||||
}
|
||||
@@ -533,7 +534,8 @@ let integrationTests =
|
||||
use conn = mkConn db
|
||||
do! loadDocs conn
|
||||
|
||||
let! doc = conn.findFirstByFields<JsonDocument> PostgresDb.TableName Any [ Field.EQ "Value" "purple" ]
|
||||
let! doc =
|
||||
conn.findFirstByFields<JsonDocument> PostgresDb.TableName Any [ Field.Equal "Value" "purple" ]
|
||||
Expect.isSome doc "There should have been a document returned"
|
||||
Expect.contains [ "five"; "four" ] doc.Value.Id "An incorrect document was returned"
|
||||
}
|
||||
@@ -542,7 +544,8 @@ let integrationTests =
|
||||
use conn = mkConn db
|
||||
do! loadDocs conn
|
||||
|
||||
let! doc = conn.findFirstByFields<JsonDocument> PostgresDb.TableName Any [ Field.EQ "Value" "absent" ]
|
||||
let! doc =
|
||||
conn.findFirstByFields<JsonDocument> PostgresDb.TableName Any [ Field.Equal "Value" "absent" ]
|
||||
Expect.isNone doc "There should not have been a document returned"
|
||||
}
|
||||
]
|
||||
@@ -554,7 +557,7 @@ let integrationTests =
|
||||
|
||||
let! doc =
|
||||
conn.findFirstByFieldsOrdered<JsonDocument>
|
||||
PostgresDb.TableName Any [ Field.EQ "Value" "purple" ] [ Field.Named "Id" ]
|
||||
PostgresDb.TableName Any [ Field.Equal "Value" "purple" ] [ Field.Named "Id" ]
|
||||
Expect.isSome doc "There should have been a document returned"
|
||||
Expect.equal "five" doc.Value.Id "An incorrect document was returned"
|
||||
}
|
||||
@@ -565,7 +568,7 @@ let integrationTests =
|
||||
|
||||
let! doc =
|
||||
conn.findFirstByFieldsOrdered<JsonDocument>
|
||||
PostgresDb.TableName Any [ Field.EQ "Value" "purple" ] [ Field.Named "Id DESC" ]
|
||||
PostgresDb.TableName Any [ Field.Equal "Value" "purple" ] [ Field.Named "Id DESC" ]
|
||||
Expect.isSome doc "There should have been a document returned"
|
||||
Expect.equal "four" doc.Value.Id "An incorrect document was returned"
|
||||
}
|
||||
@@ -750,8 +753,8 @@ let integrationTests =
|
||||
use conn = mkConn db
|
||||
do! loadDocs conn
|
||||
|
||||
do! conn.patchByFields PostgresDb.TableName Any [ Field.EQ "Value" "purple" ] {| NumValue = 77 |}
|
||||
let! after = conn.countByFields PostgresDb.TableName Any [ Field.EQ "NumValue" "77" ]
|
||||
do! conn.patchByFields PostgresDb.TableName Any [ Field.Equal "Value" "purple" ] {| NumValue = 77 |}
|
||||
let! after = conn.countByFields PostgresDb.TableName Any [ Field.Equal "NumValue" "77" ]
|
||||
Expect.equal after 2 "There should have been 2 documents returned"
|
||||
}
|
||||
testTask "succeeds when no document is updated" {
|
||||
@@ -761,7 +764,7 @@ let integrationTests =
|
||||
Expect.equal before 0 "There should have been no documents returned"
|
||||
|
||||
// This not raising an exception is the test
|
||||
do! conn.patchByFields PostgresDb.TableName Any [ Field.EQ "Value" "burgundy" ] {| Foo = "green" |}
|
||||
do! conn.patchByFields PostgresDb.TableName Any [ Field.Equal "Value" "burgundy" ] {| Foo = "green" |}
|
||||
}
|
||||
]
|
||||
testList "patchByContains" [
|
||||
@@ -811,9 +814,9 @@ let integrationTests =
|
||||
do! loadDocs conn
|
||||
|
||||
do! conn.removeFieldsById PostgresDb.TableName "two" [ "Sub"; "Value" ]
|
||||
let! noSubs = conn.countByFields PostgresDb.TableName Any [ Field.NEX "Sub" ]
|
||||
let! noSubs = conn.countByFields PostgresDb.TableName Any [ Field.NotExists "Sub" ]
|
||||
Expect.equal noSubs 4 "There should now be 4 documents without Sub fields"
|
||||
let! noValue = conn.countByFields PostgresDb.TableName Any [ Field.NEX "Value" ]
|
||||
let! noValue = conn.countByFields PostgresDb.TableName Any [ Field.NotExists "Value" ]
|
||||
Expect.equal noValue 1 "There should be 1 document without Value fields"
|
||||
}
|
||||
testTask "succeeds when a single field is removed" {
|
||||
@@ -822,9 +825,9 @@ let integrationTests =
|
||||
do! loadDocs conn
|
||||
|
||||
do! conn.removeFieldsById PostgresDb.TableName "two" [ "Sub" ]
|
||||
let! noSubs = conn.countByFields PostgresDb.TableName Any [ Field.NEX "Sub" ]
|
||||
let! noSubs = conn.countByFields PostgresDb.TableName Any [ Field.NotExists "Sub" ]
|
||||
Expect.equal noSubs 4 "There should now be 4 documents without Sub fields"
|
||||
let! noValue = conn.countByFields PostgresDb.TableName Any [ Field.NEX "Value" ]
|
||||
let! noValue = conn.countByFields PostgresDb.TableName Any [ Field.NotExists "Value" ]
|
||||
Expect.equal noValue 0 "There should be no documents without Value fields"
|
||||
}
|
||||
testTask "succeeds when a field is not removed" {
|
||||
@@ -849,10 +852,11 @@ let integrationTests =
|
||||
use conn = mkConn db
|
||||
do! loadDocs conn
|
||||
|
||||
do! conn.removeFieldsByFields PostgresDb.TableName Any [ Field.EQ "NumValue" "17" ] [ "Sub"; "Value" ]
|
||||
let! noSubs = conn.countByFields PostgresDb.TableName Any [ Field.NEX "Sub" ]
|
||||
do! conn.removeFieldsByFields
|
||||
PostgresDb.TableName Any [ Field.Equal "NumValue" "17" ] [ "Sub"; "Value" ]
|
||||
let! noSubs = conn.countByFields PostgresDb.TableName Any [ Field.NotExists "Sub" ]
|
||||
Expect.equal noSubs 4 "There should now be 4 documents without Sub fields"
|
||||
let! noValue = conn.countByFields PostgresDb.TableName Any [ Field.NEX "Value" ]
|
||||
let! noValue = conn.countByFields PostgresDb.TableName Any [ Field.NotExists "Value" ]
|
||||
Expect.equal noValue 1 "There should be 1 document without Value fields"
|
||||
}
|
||||
testTask "succeeds when a single field is removed" {
|
||||
@@ -860,10 +864,10 @@ let integrationTests =
|
||||
use conn = mkConn db
|
||||
do! loadDocs conn
|
||||
|
||||
do! conn.removeFieldsByFields PostgresDb.TableName Any [ Field.EQ "NumValue" "17" ] [ "Sub" ]
|
||||
let! noSubs = conn.countByFields PostgresDb.TableName Any [ Field.NEX "Sub" ]
|
||||
do! conn.removeFieldsByFields PostgresDb.TableName Any [ Field.Equal "NumValue" "17" ] [ "Sub" ]
|
||||
let! noSubs = conn.countByFields PostgresDb.TableName Any [ Field.NotExists "Sub" ]
|
||||
Expect.equal noSubs 4 "There should now be 4 documents without Sub fields"
|
||||
let! noValue = conn.countByFields PostgresDb.TableName Any [ Field.NEX "Value" ]
|
||||
let! noValue = conn.countByFields PostgresDb.TableName Any [ Field.NotExists "Value" ]
|
||||
Expect.equal noValue 0 "There should be no documents without Value fields"
|
||||
}
|
||||
testTask "succeeds when a field is not removed" {
|
||||
@@ -872,14 +876,15 @@ let integrationTests =
|
||||
do! loadDocs conn
|
||||
|
||||
// This not raising an exception is the test
|
||||
do! conn.removeFieldsByFields PostgresDb.TableName Any [ Field.EQ "NumValue" "17" ] [ "Nothing" ]
|
||||
do! conn.removeFieldsByFields PostgresDb.TableName Any [ Field.Equal "NumValue" "17" ] [ "Nothing" ]
|
||||
}
|
||||
testTask "succeeds when no document is matched" {
|
||||
use db = PostgresDb.BuildDb()
|
||||
use conn = mkConn db
|
||||
|
||||
// This not raising an exception is the test
|
||||
do! conn.removeFieldsByFields PostgresDb.TableName Any [ Field.NE "Abracadabra" "apple" ] [ "Value" ]
|
||||
do! conn.removeFieldsByFields
|
||||
PostgresDb.TableName Any [ Field.NotEqual "Abracadabra" "apple" ] [ "Value" ]
|
||||
}
|
||||
]
|
||||
testList "removeFieldsByContains" [
|
||||
@@ -889,9 +894,9 @@ let integrationTests =
|
||||
do! loadDocs conn
|
||||
|
||||
do! conn.removeFieldsByContains PostgresDb.TableName {| NumValue = 17 |} [ "Sub"; "Value" ]
|
||||
let! noSubs = conn.countByFields PostgresDb.TableName Any [ Field.NEX "Sub" ]
|
||||
let! noSubs = conn.countByFields PostgresDb.TableName Any [ Field.NotExists "Sub" ]
|
||||
Expect.equal noSubs 4 "There should now be 4 documents without Sub fields"
|
||||
let! noValue = conn.countByFields PostgresDb.TableName Any [ Field.NEX "Value" ]
|
||||
let! noValue = conn.countByFields PostgresDb.TableName Any [ Field.NotExists "Value" ]
|
||||
Expect.equal noValue 1 "There should be 1 document without Value fields"
|
||||
}
|
||||
testTask "succeeds when a single field is removed" {
|
||||
@@ -900,9 +905,9 @@ let integrationTests =
|
||||
do! loadDocs conn
|
||||
|
||||
do! conn.removeFieldsByContains PostgresDb.TableName {| NumValue = 17 |} [ "Sub" ]
|
||||
let! noSubs = conn.countByFields PostgresDb.TableName Any [ Field.NEX "Sub" ]
|
||||
let! noSubs = conn.countByFields PostgresDb.TableName Any [ Field.NotExists "Sub" ]
|
||||
Expect.equal noSubs 4 "There should now be 4 documents without Sub fields"
|
||||
let! noValue = conn.countByFields PostgresDb.TableName Any [ Field.NEX "Value" ]
|
||||
let! noValue = conn.countByFields PostgresDb.TableName Any [ Field.NotExists "Value" ]
|
||||
Expect.equal noValue 0 "There should be no documents without Value fields"
|
||||
}
|
||||
testTask "succeeds when a field is not removed" {
|
||||
@@ -928,9 +933,9 @@ let integrationTests =
|
||||
do! loadDocs conn
|
||||
|
||||
do! conn.removeFieldsByJsonPath PostgresDb.TableName "$.NumValue ? (@ == 17)" [ "Sub"; "Value" ]
|
||||
let! noSubs = conn.countByFields PostgresDb.TableName Any [ Field.NEX "Sub" ]
|
||||
let! noSubs = conn.countByFields PostgresDb.TableName Any [ Field.NotExists "Sub" ]
|
||||
Expect.equal noSubs 4 "There should now be 4 documents without Sub fields"
|
||||
let! noValue = conn.countByFields PostgresDb.TableName Any [ Field.NEX "Value" ]
|
||||
let! noValue = conn.countByFields PostgresDb.TableName Any [ Field.NotExists "Value" ]
|
||||
Expect.equal noValue 1 "There should be 1 document without Value fields"
|
||||
}
|
||||
testTask "succeeds when a single field is removed" {
|
||||
@@ -939,9 +944,9 @@ let integrationTests =
|
||||
do! loadDocs conn
|
||||
|
||||
do! conn.removeFieldsByJsonPath PostgresDb.TableName "$.NumValue ? (@ == 17)" [ "Sub" ]
|
||||
let! noSubs = conn.countByFields PostgresDb.TableName Any [ Field.NEX "Sub" ]
|
||||
let! noSubs = conn.countByFields PostgresDb.TableName Any [ Field.NotExists "Sub" ]
|
||||
Expect.equal noSubs 4 "There should now be 4 documents without Sub fields"
|
||||
let! noValue = conn.countByFields PostgresDb.TableName Any [ Field.NEX "Value" ]
|
||||
let! noValue = conn.countByFields PostgresDb.TableName Any [ Field.NotExists "Value" ]
|
||||
Expect.equal noValue 0 "There should be no documents without Value fields"
|
||||
}
|
||||
testTask "succeeds when a field is not removed" {
|
||||
@@ -986,7 +991,7 @@ let integrationTests =
|
||||
use conn = mkConn db
|
||||
do! loadDocs conn
|
||||
|
||||
do! conn.deleteByFields PostgresDb.TableName Any [ Field.EQ "Value" "purple" ]
|
||||
do! conn.deleteByFields PostgresDb.TableName Any [ Field.Equal "Value" "purple" ]
|
||||
let! remaining = conn.countAll PostgresDb.TableName
|
||||
Expect.equal remaining 3 "There should have been 3 documents remaining"
|
||||
}
|
||||
@@ -995,7 +1000,7 @@ let integrationTests =
|
||||
use conn = mkConn db
|
||||
do! loadDocs conn
|
||||
|
||||
do! conn.deleteByFields PostgresDb.TableName Any [ Field.EQ "Value" "crimson" ]
|
||||
do! conn.deleteByFields PostgresDb.TableName Any [ Field.Equal "Value" "crimson" ]
|
||||
let! remaining = conn.countAll PostgresDb.TableName
|
||||
Expect.equal remaining 5 "There should have been 5 documents remaining"
|
||||
}
|
||||
|
||||
@@ -83,14 +83,14 @@ let parametersTests = testList "Parameters" [
|
||||
}
|
||||
testList "addFieldParams" [
|
||||
test "succeeds when a parameter is added" {
|
||||
let paramList = addFieldParams [ Field.EQ "it" "242" ] []
|
||||
let paramList = addFieldParams [ Field.Where "it" (Equal "242") ] []
|
||||
Expect.hasLength paramList 1 "There should have been a parameter added"
|
||||
let name, value = Seq.head paramList
|
||||
Expect.equal name "@field0" "Field parameter name not correct"
|
||||
Expect.equal value (Sql.string "242") "Parameter value not correct"
|
||||
}
|
||||
test "succeeds when multiple independent parameters are added" {
|
||||
let paramList = addFieldParams [ Field.EQ "me" "you"; Field.GT "us" "them" ] [ idParam 14 ]
|
||||
let paramList = addFieldParams [ Field.Equal "me" "you"; Field.Greater "us" "them" ] [ idParam 14 ]
|
||||
Expect.hasLength paramList 3 "There should have been 2 parameters added"
|
||||
let p = Array.ofSeq paramList
|
||||
Expect.equal (fst p[0]) "@id" "First field parameter name not correct"
|
||||
@@ -101,11 +101,11 @@ let parametersTests = testList "Parameters" [
|
||||
Expect.equal (snd p[2]) (Sql.string "them") "Third parameter value not correct"
|
||||
}
|
||||
test "succeeds when a parameter is not added" {
|
||||
let paramList = addFieldParams [ Field.EX "tacos" ] []
|
||||
let paramList = addFieldParams [ Field.Exists "tacos" ] []
|
||||
Expect.isEmpty paramList "There should not have been any parameters added"
|
||||
}
|
||||
test "succeeds when two parameters are added for one field" {
|
||||
let paramList = addFieldParams [ { Field.BT "that" "eh" "zed" with ParameterName = Some "@test" } ] []
|
||||
let paramList = addFieldParams [ { Field.Between "that" "eh" "zed" with ParameterName = Some "@test" } ] []
|
||||
Expect.hasLength paramList 2 "There should have been 2 parameters added"
|
||||
let name, value = Seq.head paramList
|
||||
Expect.equal name "@testmin" "Minimum field name not correct"
|
||||
@@ -135,48 +135,66 @@ let parametersTests = testList "Parameters" [
|
||||
/// Unit tests for the Query module of the PostgreSQL library
|
||||
let queryTests = testList "Query" [
|
||||
testList "whereByFields" [
|
||||
test "succeeds for a single field when a logical operator is passed" {
|
||||
test "succeeds for a single field when a logical comparison is passed" {
|
||||
Expect.equal
|
||||
(Query.whereByFields Any [ { Field.GT "theField" "0" with ParameterName = Some "@test" } ])
|
||||
(Query.whereByFields Any [ { Field.Greater "theField" "0" with ParameterName = Some "@test" } ])
|
||||
"data->>'theField' > @test"
|
||||
"WHERE clause not correct"
|
||||
}
|
||||
test "succeeds for a single field when an existence operator is passed" {
|
||||
test "succeeds for a single field when an existence comparison is passed" {
|
||||
Expect.equal
|
||||
(Query.whereByFields Any [ Field.NEX "thatField" ])
|
||||
(Query.whereByFields Any [ Field.NotExists "thatField" ])
|
||||
"data->>'thatField' IS NULL"
|
||||
"WHERE clause not correct"
|
||||
}
|
||||
test "succeeds for a single field when a between operator is passed with numeric values" {
|
||||
test "succeeds for a single field when a between comparison is passed with numeric values" {
|
||||
Expect.equal
|
||||
(Query.whereByFields All [ { Field.BT "aField" 50 99 with ParameterName = Some "@range" } ])
|
||||
(Query.whereByFields All [ { Field.Between "aField" 50 99 with ParameterName = Some "@range" } ])
|
||||
"(data->>'aField')::numeric BETWEEN @rangemin AND @rangemax"
|
||||
"WHERE clause not correct"
|
||||
}
|
||||
test "succeeds for a single field when a between operator is passed with non-numeric values" {
|
||||
test "succeeds for a single field when a between comparison is passed with non-numeric values" {
|
||||
Expect.equal
|
||||
(Query.whereByFields Any [ { Field.BT "field0" "a" "b" with ParameterName = Some "@alpha" } ])
|
||||
(Query.whereByFields Any [ { Field.Between "field0" "a" "b" with ParameterName = Some "@alpha" } ])
|
||||
"data->>'field0' BETWEEN @alphamin AND @alphamax"
|
||||
"WHERE clause not correct"
|
||||
}
|
||||
test "succeeds for all multiple fields with logical operators" {
|
||||
test "succeeds for all multiple fields with logical comparisons" {
|
||||
Expect.equal
|
||||
(Query.whereByFields All [ Field.EQ "theFirst" "1"; Field.EQ "numberTwo" "2" ])
|
||||
(Query.whereByFields All [ Field.Equal "theFirst" "1"; Field.Equal "numberTwo" "2" ])
|
||||
"data->>'theFirst' = @field0 AND data->>'numberTwo' = @field1"
|
||||
"WHERE clause not correct"
|
||||
}
|
||||
test "succeeds for any multiple fields with an existence operator" {
|
||||
test "succeeds for any multiple fields with an existence comparisons" {
|
||||
Expect.equal
|
||||
(Query.whereByFields Any [ Field.NEX "thatField"; Field.GE "thisField" 18 ])
|
||||
(Query.whereByFields Any [ Field.NotExists "thatField"; Field.GreaterOrEqual "thisField" 18 ])
|
||||
"data->>'thatField' IS NULL OR (data->>'thisField')::numeric >= @field0"
|
||||
"WHERE clause not correct"
|
||||
}
|
||||
test "succeeds for all multiple fields with between operators" {
|
||||
test "succeeds for all multiple fields with between comparisons" {
|
||||
Expect.equal
|
||||
(Query.whereByFields All [ Field.BT "aField" 50 99; Field.BT "anotherField" "a" "b" ])
|
||||
(Query.whereByFields All [ Field.Between "aField" 50 99; Field.Between "anotherField" "a" "b" ])
|
||||
"(data->>'aField')::numeric BETWEEN @field0min AND @field0max AND data->>'anotherField' BETWEEN @field1min AND @field1max"
|
||||
"WHERE clause not correct"
|
||||
}
|
||||
test "succeeds for a field with an In comparison with alphanumeric values" {
|
||||
Expect.equal
|
||||
(Query.whereByFields All [ Field.In "this" [ "a"; "b"; "c" ] ])
|
||||
"data->>'this' IN (@field0_0, @field0_1, @field0_2)"
|
||||
"WHERE clause not correct"
|
||||
}
|
||||
test "succeeds for a field with an In comparison with numeric values" {
|
||||
Expect.equal
|
||||
(Query.whereByFields All [ Field.In "this" [ 7; 14; 21 ] ])
|
||||
"(data->>'this')::numeric IN (@field0_0, @field0_1, @field0_2)"
|
||||
"WHERE clause not correct"
|
||||
}
|
||||
test "succeeds for a field with an InArray comparison" {
|
||||
Expect.equal
|
||||
(Query.whereByFields All [ Field.InArray "theField" "the_table" [ "q", "r" ] ])
|
||||
"data->'theField' ?| @field0"
|
||||
"WHERE clause not correct"
|
||||
}
|
||||
]
|
||||
testList "whereById" [
|
||||
test "succeeds for numeric ID" {
|
||||
@@ -234,7 +252,7 @@ let queryTests = testList "Query" [
|
||||
}
|
||||
test "byFields succeeds" {
|
||||
Expect.equal
|
||||
(Query.byFields "unit" Any [ Field.GT "That" 14 ])
|
||||
(Query.byFields "unit" Any [ Field.Greater "That" 14 ])
|
||||
"unit WHERE (data->>'That')::numeric > @field0"
|
||||
"By-Field query not correct"
|
||||
}
|
||||
@@ -532,14 +550,15 @@ let countTests = testList "Count" [
|
||||
use db = PostgresDb.BuildDb()
|
||||
do! loadDocs ()
|
||||
|
||||
let! theCount = Count.byFields PostgresDb.TableName Any [ Field.BT "NumValue" 15 20; Field.EQ "NumValue" 0 ]
|
||||
let! theCount =
|
||||
Count.byFields PostgresDb.TableName Any [ Field.Between "NumValue" 15 20; Field.Equal "NumValue" 0 ]
|
||||
Expect.equal theCount 3 "There should have been 3 matching documents"
|
||||
}
|
||||
testTask "succeeds when items are not found" {
|
||||
use db = PostgresDb.BuildDb()
|
||||
do! loadDocs ()
|
||||
|
||||
let! theCount = Count.byFields PostgresDb.TableName All [ Field.EX "Sub"; Field.GT "NumValue" 100 ]
|
||||
let! theCount = Count.byFields PostgresDb.TableName All [ Field.Exists "Sub"; Field.Greater "NumValue" 100 ]
|
||||
Expect.equal theCount 0 "There should have been no matching documents"
|
||||
}
|
||||
]
|
||||
@@ -582,14 +601,14 @@ let existsTests = testList "Exists" [
|
||||
use db = PostgresDb.BuildDb()
|
||||
do! loadDocs ()
|
||||
|
||||
let! exists = Exists.byFields PostgresDb.TableName Any [ Field.EX "Sub"; Field.EX "Boo" ]
|
||||
let! exists = Exists.byFields PostgresDb.TableName Any [ Field.Exists "Sub"; Field.Exists "Boo" ]
|
||||
Expect.isTrue exists "There should have been existing documents"
|
||||
}
|
||||
testTask "succeeds when documents do not exist" {
|
||||
use db = PostgresDb.BuildDb()
|
||||
do! loadDocs ()
|
||||
|
||||
let! exists = Exists.byFields PostgresDb.TableName All [ Field.EQ "NumValue" "six"; Field.EX "Nope" ]
|
||||
let! exists = Exists.byFields PostgresDb.TableName All [ Field.Equal "NumValue" "six"; Field.Exists "Nope" ]
|
||||
Expect.isFalse exists "There should not have been existing documents"
|
||||
}
|
||||
]
|
||||
@@ -707,8 +726,16 @@ let findTests = testList "Find" [
|
||||
do! loadDocs ()
|
||||
|
||||
let! docs =
|
||||
Find.byFields<JsonDocument> PostgresDb.TableName All [ Field.EQ "Value" "purple"; Field.EX "Sub" ]
|
||||
Expect.equal (List.length docs) 1 "There should have been one document returned"
|
||||
Find.byFields<JsonDocument>
|
||||
PostgresDb.TableName All [ Field.In "Value" [ "purple"; "blue" ]; Field.Exists "Sub" ]
|
||||
Expect.hasLength docs 1 "There should have been one document returned"
|
||||
}
|
||||
testTask "succeeds when documents are found using IN with numeric field" {
|
||||
use db = PostgresDb.BuildDb()
|
||||
do! loadDocs ()
|
||||
|
||||
let! docs = Find.byFields<JsonDocument> PostgresDb.TableName All [ Field.In "NumValue" [ 2; 4; 6; 8 ] ]
|
||||
Expect.hasLength docs 1 "There should have been one document returned"
|
||||
}
|
||||
testTask "succeeds when documents are not found" {
|
||||
use db = PostgresDb.BuildDb()
|
||||
@@ -716,7 +743,27 @@ let findTests = testList "Find" [
|
||||
|
||||
let! docs =
|
||||
Find.byFields<JsonDocument>
|
||||
PostgresDb.TableName All [ Field.EQ "Value" "mauve"; Field.NE "NumValue" 40 ]
|
||||
PostgresDb.TableName All [ Field.Equal "Value" "mauve"; Field.NotEqual "NumValue" 40 ]
|
||||
Expect.isEmpty docs "There should have been no documents returned"
|
||||
}
|
||||
testTask "succeeds for InArray when matching documents exist" {
|
||||
use db = PostgresDb.BuildDb()
|
||||
do! Definition.ensureTable PostgresDb.TableName
|
||||
for doc in ArrayDocument.TestDocuments do do! insert PostgresDb.TableName doc
|
||||
|
||||
let! docs =
|
||||
Find.byFields<ArrayDocument>
|
||||
PostgresDb.TableName All [ Field.InArray "Values" PostgresDb.TableName [ "c" ] ]
|
||||
Expect.hasLength docs 2 "There should have been two documents returned"
|
||||
}
|
||||
testTask "succeeds for InArray when no matching documents exist" {
|
||||
use db = PostgresDb.BuildDb()
|
||||
do! Definition.ensureTable PostgresDb.TableName
|
||||
for doc in ArrayDocument.TestDocuments do do! insert PostgresDb.TableName doc
|
||||
|
||||
let! docs =
|
||||
Find.byFields<ArrayDocument>
|
||||
PostgresDb.TableName All [ Field.InArray "Values" PostgresDb.TableName [ "j" ] ]
|
||||
Expect.isEmpty docs "There should have been no documents returned"
|
||||
}
|
||||
]
|
||||
@@ -727,7 +774,7 @@ let findTests = testList "Find" [
|
||||
|
||||
let! docs =
|
||||
Find.byFieldsOrdered<JsonDocument>
|
||||
PostgresDb.TableName All [ Field.EQ "Value" "purple" ] [ Field.Named "Id" ]
|
||||
PostgresDb.TableName All [ Field.Equal "Value" "purple" ] [ Field.Named "Id" ]
|
||||
Expect.hasLength docs 2 "There should have been two documents returned"
|
||||
Expect.equal
|
||||
(docs |> List.map _.Id |> String.concat "|") "five|four" "Documents not ordered correctly"
|
||||
@@ -738,7 +785,7 @@ let findTests = testList "Find" [
|
||||
|
||||
let! docs =
|
||||
Find.byFieldsOrdered<JsonDocument>
|
||||
PostgresDb.TableName All [ Field.EQ "Value" "purple" ] [ Field.Named "Id DESC" ]
|
||||
PostgresDb.TableName All [ Field.Equal "Value" "purple" ] [ Field.Named "Id DESC" ]
|
||||
Expect.hasLength docs 2 "There should have been two documents returned"
|
||||
Expect.equal
|
||||
(docs |> List.map _.Id |> String.concat "|") "four|five" "Documents not ordered correctly"
|
||||
@@ -831,7 +878,7 @@ let findTests = testList "Find" [
|
||||
use db = PostgresDb.BuildDb()
|
||||
do! loadDocs ()
|
||||
|
||||
let! doc = Find.firstByFields<JsonDocument> PostgresDb.TableName Any [ Field.EQ "Value" "another" ]
|
||||
let! doc = Find.firstByFields<JsonDocument> PostgresDb.TableName Any [ Field.Equal "Value" "another" ]
|
||||
Expect.isSome doc "There should have been a document returned"
|
||||
Expect.equal doc.Value.Id "two" "The incorrect document was returned"
|
||||
}
|
||||
@@ -839,7 +886,7 @@ let findTests = testList "Find" [
|
||||
use db = PostgresDb.BuildDb()
|
||||
do! loadDocs ()
|
||||
|
||||
let! doc = Find.firstByFields<JsonDocument> PostgresDb.TableName Any [ Field.EQ "Value" "purple" ]
|
||||
let! doc = Find.firstByFields<JsonDocument> PostgresDb.TableName Any [ Field.Equal "Value" "purple" ]
|
||||
Expect.isSome doc "There should have been a document returned"
|
||||
Expect.contains [ "five"; "four" ] doc.Value.Id "An incorrect document was returned"
|
||||
}
|
||||
@@ -847,7 +894,7 @@ let findTests = testList "Find" [
|
||||
use db = PostgresDb.BuildDb()
|
||||
do! loadDocs ()
|
||||
|
||||
let! doc = Find.firstByFields<JsonDocument> PostgresDb.TableName Any [ Field.EQ "Value" "absent" ]
|
||||
let! doc = Find.firstByFields<JsonDocument> PostgresDb.TableName Any [ Field.Equal "Value" "absent" ]
|
||||
Expect.isNone doc "There should not have been a document returned"
|
||||
}
|
||||
]
|
||||
@@ -858,7 +905,7 @@ let findTests = testList "Find" [
|
||||
|
||||
let! doc =
|
||||
Find.firstByFieldsOrdered<JsonDocument>
|
||||
PostgresDb.TableName Any [ Field.EQ "Value" "purple" ] [ Field.Named "Id" ]
|
||||
PostgresDb.TableName Any [ Field.Equal "Value" "purple" ] [ Field.Named "Id" ]
|
||||
Expect.isSome doc "There should have been a document returned"
|
||||
Expect.equal "five" doc.Value.Id "An incorrect document was returned"
|
||||
}
|
||||
@@ -868,7 +915,7 @@ let findTests = testList "Find" [
|
||||
|
||||
let! doc =
|
||||
Find.firstByFieldsOrdered<JsonDocument>
|
||||
PostgresDb.TableName Any [ Field.EQ "Value" "purple" ] [ Field.Named "Id DESC" ]
|
||||
PostgresDb.TableName Any [ Field.Equal "Value" "purple" ] [ Field.Named "Id DESC" ]
|
||||
Expect.isSome doc "There should have been a document returned"
|
||||
Expect.equal "four" doc.Value.Id "An incorrect document was returned"
|
||||
}
|
||||
@@ -1045,8 +1092,8 @@ let patchTests = testList "Patch" [
|
||||
use db = PostgresDb.BuildDb()
|
||||
do! loadDocs ()
|
||||
|
||||
do! Patch.byFields PostgresDb.TableName Any [ Field.EQ "Value" "purple" ] {| NumValue = 77 |}
|
||||
let! after = Count.byFields PostgresDb.TableName Any [ Field.EQ "NumValue" 77 ]
|
||||
do! Patch.byFields PostgresDb.TableName Any [ Field.Equal "Value" "purple" ] {| NumValue = 77 |}
|
||||
let! after = Count.byFields PostgresDb.TableName Any [ Field.Equal "NumValue" 77 ]
|
||||
Expect.equal after 2 "There should have been 2 documents returned"
|
||||
}
|
||||
testTask "succeeds when no document is updated" {
|
||||
@@ -1056,7 +1103,7 @@ let patchTests = testList "Patch" [
|
||||
Expect.equal before 0 "There should have been no documents returned"
|
||||
|
||||
// This not raising an exception is the test
|
||||
do! Patch.byFields PostgresDb.TableName Any [ Field.EQ "Value" "burgundy" ] {| Foo = "green" |}
|
||||
do! Patch.byFields PostgresDb.TableName Any [ Field.Equal "Value" "burgundy" ] {| Foo = "green" |}
|
||||
}
|
||||
]
|
||||
testList "byContains" [
|
||||
@@ -1107,9 +1154,9 @@ let removeFieldsTests = testList "RemoveFields" [
|
||||
do! loadDocs ()
|
||||
|
||||
do! RemoveFields.byId PostgresDb.TableName "two" [ "Sub"; "Value" ]
|
||||
let! noSubs = Count.byFields PostgresDb.TableName Any [ Field.NEX "Sub" ]
|
||||
let! noSubs = Count.byFields PostgresDb.TableName Any [ Field.NotExists "Sub" ]
|
||||
Expect.equal noSubs 4 "There should now be 4 documents without Sub fields"
|
||||
let! noValue = Count.byFields PostgresDb.TableName Any [ Field.NEX "Value" ]
|
||||
let! noValue = Count.byFields PostgresDb.TableName Any [ Field.NotExists "Value" ]
|
||||
Expect.equal noValue 1 "There should be 1 document without Value fields"
|
||||
}
|
||||
testTask "succeeds when a single field is removed" {
|
||||
@@ -1117,9 +1164,9 @@ let removeFieldsTests = testList "RemoveFields" [
|
||||
do! loadDocs ()
|
||||
|
||||
do! RemoveFields.byId PostgresDb.TableName "two" [ "Sub" ]
|
||||
let! noSubs = Count.byFields PostgresDb.TableName Any [ Field.NEX "Sub" ]
|
||||
let! noSubs = Count.byFields PostgresDb.TableName Any [ Field.NotExists "Sub" ]
|
||||
Expect.equal noSubs 4 "There should now be 4 documents without Sub fields"
|
||||
let! noValue = Count.byFields PostgresDb.TableName Any [ Field.NEX "Value" ]
|
||||
let! noValue = Count.byFields PostgresDb.TableName Any [ Field.NotExists "Value" ]
|
||||
Expect.equal noValue 0 "There should be no documents without Value fields"
|
||||
}
|
||||
testTask "succeeds when a field is not removed" {
|
||||
@@ -1141,20 +1188,20 @@ let removeFieldsTests = testList "RemoveFields" [
|
||||
use db = PostgresDb.BuildDb()
|
||||
do! loadDocs ()
|
||||
|
||||
do! RemoveFields.byFields PostgresDb.TableName Any [ Field.EQ "NumValue" "17" ] [ "Sub"; "Value" ]
|
||||
let! noSubs = Count.byFields PostgresDb.TableName Any [ Field.NEX "Sub" ]
|
||||
do! RemoveFields.byFields PostgresDb.TableName Any [ Field.Equal "NumValue" 17 ] [ "Sub"; "Value" ]
|
||||
let! noSubs = Count.byFields PostgresDb.TableName Any [ Field.NotExists "Sub" ]
|
||||
Expect.equal noSubs 4 "There should now be 4 documents without Sub fields"
|
||||
let! noValue = Count.byFields PostgresDb.TableName Any [ Field.NEX "Value" ]
|
||||
let! noValue = Count.byFields PostgresDb.TableName Any [ Field.NotExists "Value" ]
|
||||
Expect.equal noValue 1 "There should be 1 document without Value fields"
|
||||
}
|
||||
testTask "succeeds when a single field is removed" {
|
||||
use db = PostgresDb.BuildDb()
|
||||
do! loadDocs ()
|
||||
|
||||
do! RemoveFields.byFields PostgresDb.TableName Any [ Field.EQ "NumValue" "17" ] [ "Sub" ]
|
||||
let! noSubs = Count.byFields PostgresDb.TableName Any [ Field.NEX "Sub" ]
|
||||
do! RemoveFields.byFields PostgresDb.TableName Any [ Field.Equal "NumValue" 17 ] [ "Sub" ]
|
||||
let! noSubs = Count.byFields PostgresDb.TableName Any [ Field.NotExists "Sub" ]
|
||||
Expect.equal noSubs 4 "There should now be 4 documents without Sub fields"
|
||||
let! noValue = Count.byFields PostgresDb.TableName Any [ Field.NEX "Value" ]
|
||||
let! noValue = Count.byFields PostgresDb.TableName Any [ Field.NotExists "Value" ]
|
||||
Expect.equal noValue 0 "There should be no documents without Value fields"
|
||||
}
|
||||
testTask "succeeds when a field is not removed" {
|
||||
@@ -1162,13 +1209,13 @@ let removeFieldsTests = testList "RemoveFields" [
|
||||
do! loadDocs ()
|
||||
|
||||
// This not raising an exception is the test
|
||||
do! RemoveFields.byFields PostgresDb.TableName Any [ Field.EQ "NumValue" "17" ] [ "Nothing" ]
|
||||
do! RemoveFields.byFields PostgresDb.TableName Any [ Field.Equal "NumValue" 17 ] [ "Nothing" ]
|
||||
}
|
||||
testTask "succeeds when no document is matched" {
|
||||
use db = PostgresDb.BuildDb()
|
||||
|
||||
// This not raising an exception is the test
|
||||
do! RemoveFields.byFields PostgresDb.TableName Any [ Field.NE "Abracadabra" "apple" ] [ "Value" ]
|
||||
do! RemoveFields.byFields PostgresDb.TableName Any [ Field.NotEqual "Abracadabra" "apple" ] [ "Value" ]
|
||||
}
|
||||
]
|
||||
testList "byContains" [
|
||||
@@ -1177,9 +1224,9 @@ let removeFieldsTests = testList "RemoveFields" [
|
||||
do! loadDocs ()
|
||||
|
||||
do! RemoveFields.byContains PostgresDb.TableName {| NumValue = 17 |} [ "Sub"; "Value" ]
|
||||
let! noSubs = Count.byFields PostgresDb.TableName Any [ Field.NEX "Sub" ]
|
||||
let! noSubs = Count.byFields PostgresDb.TableName Any [ Field.NotExists "Sub" ]
|
||||
Expect.equal noSubs 4 "There should now be 4 documents without Sub fields"
|
||||
let! noValue = Count.byFields PostgresDb.TableName Any [ Field.NEX "Value" ]
|
||||
let! noValue = Count.byFields PostgresDb.TableName Any [ Field.NotExists "Value" ]
|
||||
Expect.equal noValue 1 "There should be 1 document without Value fields"
|
||||
}
|
||||
testTask "succeeds when a single field is removed" {
|
||||
@@ -1187,9 +1234,9 @@ let removeFieldsTests = testList "RemoveFields" [
|
||||
do! loadDocs ()
|
||||
|
||||
do! RemoveFields.byContains PostgresDb.TableName {| NumValue = 17 |} [ "Sub" ]
|
||||
let! noSubs = Count.byFields PostgresDb.TableName Any [ Field.NEX "Sub" ]
|
||||
let! noSubs = Count.byFields PostgresDb.TableName Any [ Field.NotExists "Sub" ]
|
||||
Expect.equal noSubs 4 "There should now be 4 documents without Sub fields"
|
||||
let! noValue = Count.byFields PostgresDb.TableName Any [ Field.NEX "Value" ]
|
||||
let! noValue = Count.byFields PostgresDb.TableName Any [ Field.NotExists "Value" ]
|
||||
Expect.equal noValue 0 "There should be no documents without Value fields"
|
||||
}
|
||||
testTask "succeeds when a field is not removed" {
|
||||
@@ -1212,9 +1259,9 @@ let removeFieldsTests = testList "RemoveFields" [
|
||||
do! loadDocs ()
|
||||
|
||||
do! RemoveFields.byJsonPath PostgresDb.TableName "$.NumValue ? (@ == 17)" [ "Sub"; "Value" ]
|
||||
let! noSubs = Count.byFields PostgresDb.TableName Any [ Field.NEX "Sub" ]
|
||||
let! noSubs = Count.byFields PostgresDb.TableName Any [ Field.NotExists "Sub" ]
|
||||
Expect.equal noSubs 4 "There should now be 4 documents without Sub fields"
|
||||
let! noValue = Count.byFields PostgresDb.TableName Any [ Field.NEX "Value" ]
|
||||
let! noValue = Count.byFields PostgresDb.TableName Any [ Field.NotExists "Value" ]
|
||||
Expect.equal noValue 1 "There should be 1 document without Value fields"
|
||||
}
|
||||
testTask "succeeds when a single field is removed" {
|
||||
@@ -1222,9 +1269,9 @@ let removeFieldsTests = testList "RemoveFields" [
|
||||
do! loadDocs ()
|
||||
|
||||
do! RemoveFields.byJsonPath PostgresDb.TableName "$.NumValue ? (@ == 17)" [ "Sub" ]
|
||||
let! noSubs = Count.byFields PostgresDb.TableName Any [ Field.NEX "Sub" ]
|
||||
let! noSubs = Count.byFields PostgresDb.TableName Any [ Field.NotExists "Sub" ]
|
||||
Expect.equal noSubs 4 "There should now be 4 documents without Sub fields"
|
||||
let! noValue = Count.byFields PostgresDb.TableName Any [ Field.NEX "Value" ]
|
||||
let! noValue = Count.byFields PostgresDb.TableName Any [ Field.NotExists "Value" ]
|
||||
Expect.equal noValue 0 "There should be no documents without Value fields"
|
||||
}
|
||||
testTask "succeeds when a field is not removed" {
|
||||
@@ -1268,7 +1315,7 @@ let deleteTests = testList "Delete" [
|
||||
use db = PostgresDb.BuildDb()
|
||||
do! loadDocs ()
|
||||
|
||||
do! Delete.byFields PostgresDb.TableName Any [ Field.EQ "Value" "purple" ]
|
||||
do! Delete.byFields PostgresDb.TableName Any [ Field.Equal "Value" "purple" ]
|
||||
let! remaining = Count.all PostgresDb.TableName
|
||||
Expect.equal remaining 3 "There should have been 3 documents remaining"
|
||||
}
|
||||
@@ -1276,7 +1323,7 @@ let deleteTests = testList "Delete" [
|
||||
use db = PostgresDb.BuildDb()
|
||||
do! loadDocs ()
|
||||
|
||||
do! Delete.byFields PostgresDb.TableName Any [ Field.EQ "Value" "crimson" ]
|
||||
do! Delete.byFields PostgresDb.TableName Any [ Field.Equal "Value" "crimson" ]
|
||||
let! remaining = Count.all PostgresDb.TableName
|
||||
Expect.equal remaining 5 "There should have been 5 documents remaining"
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ let integrationTests =
|
||||
use conn = Configuration.dbConn ()
|
||||
do! loadDocs ()
|
||||
|
||||
let! theCount = conn.countByFields SqliteDb.TableName Any [ Field.EQ "Value" "purple" ]
|
||||
let! theCount = conn.countByFields SqliteDb.TableName Any [ Field.Equal "Value" "purple" ]
|
||||
Expect.equal theCount 2L "There should have been 2 matching documents"
|
||||
}
|
||||
testList "existsById" [
|
||||
@@ -145,7 +145,7 @@ let integrationTests =
|
||||
use conn = Configuration.dbConn ()
|
||||
do! loadDocs ()
|
||||
|
||||
let! exists = conn.existsByFields SqliteDb.TableName Any [ Field.EQ "NumValue" 10 ]
|
||||
let! exists = conn.existsByFields SqliteDb.TableName Any [ Field.Equal "NumValue" 10 ]
|
||||
Expect.isTrue exists "There should have been existing documents"
|
||||
}
|
||||
testTask "succeeds when no matching documents exist" {
|
||||
@@ -153,7 +153,7 @@ let integrationTests =
|
||||
use conn = Configuration.dbConn ()
|
||||
do! loadDocs ()
|
||||
|
||||
let! exists = conn.existsByFields SqliteDb.TableName Any [ Field.EQ "Nothing" "none" ]
|
||||
let! exists = conn.existsByFields SqliteDb.TableName Any [ Field.Equal "Nothing" "none" ]
|
||||
Expect.isFalse exists "There should not have been any existing documents"
|
||||
}
|
||||
]
|
||||
@@ -244,7 +244,7 @@ let integrationTests =
|
||||
use conn = Configuration.dbConn ()
|
||||
do! loadDocs ()
|
||||
|
||||
let! docs = conn.findByFields<JsonDocument> SqliteDb.TableName Any [ Field.EQ "Sub.Foo" "green" ]
|
||||
let! docs = conn.findByFields<JsonDocument> SqliteDb.TableName Any [ Field.Equal "Sub.Foo" "green" ]
|
||||
Expect.hasLength docs 2 "There should have been two documents returned"
|
||||
}
|
||||
testTask "succeeds when documents are not found" {
|
||||
@@ -252,7 +252,7 @@ let integrationTests =
|
||||
use conn = Configuration.dbConn ()
|
||||
do! loadDocs ()
|
||||
|
||||
let! docs = conn.findByFields<JsonDocument> SqliteDb.TableName Any [ Field.EQ "Value" "mauve" ]
|
||||
let! docs = conn.findByFields<JsonDocument> SqliteDb.TableName Any [ Field.Equal "Value" "mauve" ]
|
||||
Expect.isEmpty docs "There should have been no documents returned"
|
||||
}
|
||||
]
|
||||
@@ -264,7 +264,7 @@ let integrationTests =
|
||||
|
||||
let! docs =
|
||||
conn.findByFieldsOrdered<JsonDocument>
|
||||
SqliteDb.TableName Any [ Field.GT "NumValue" 15 ] [ Field.Named "Id" ]
|
||||
SqliteDb.TableName Any [ Field.Greater "NumValue" 15 ] [ Field.Named "Id" ]
|
||||
Expect.equal
|
||||
(docs |> List.map _.Id |> String.concat "|") "five|four" "The documents were not ordered correctly"
|
||||
}
|
||||
@@ -275,7 +275,7 @@ let integrationTests =
|
||||
|
||||
let! docs =
|
||||
conn.findByFieldsOrdered<JsonDocument>
|
||||
SqliteDb.TableName Any [ Field.GT "NumValue" 15 ] [ Field.Named "Id DESC" ]
|
||||
SqliteDb.TableName Any [ Field.Greater "NumValue" 15 ] [ Field.Named "Id DESC" ]
|
||||
Expect.equal
|
||||
(docs |> List.map _.Id |> String.concat "|") "four|five" "The documents were not ordered correctly"
|
||||
}
|
||||
@@ -286,7 +286,7 @@ let integrationTests =
|
||||
use conn = Configuration.dbConn ()
|
||||
do! loadDocs ()
|
||||
|
||||
let! doc = conn.findFirstByFields<JsonDocument> SqliteDb.TableName Any [ Field.EQ "Value" "another" ]
|
||||
let! doc = conn.findFirstByFields<JsonDocument> SqliteDb.TableName Any [ Field.Equal "Value" "another" ]
|
||||
Expect.isSome doc "There should have been a document returned"
|
||||
Expect.equal doc.Value.Id "two" "The incorrect document was returned"
|
||||
}
|
||||
@@ -295,7 +295,7 @@ let integrationTests =
|
||||
use conn = Configuration.dbConn ()
|
||||
do! loadDocs ()
|
||||
|
||||
let! doc = conn.findFirstByFields<JsonDocument> SqliteDb.TableName Any [ Field.EQ "Sub.Foo" "green" ]
|
||||
let! doc = conn.findFirstByFields<JsonDocument> SqliteDb.TableName Any [ Field.Equal "Sub.Foo" "green" ]
|
||||
Expect.isSome doc "There should have been a document returned"
|
||||
Expect.contains [ "two"; "four" ] doc.Value.Id "An incorrect document was returned"
|
||||
}
|
||||
@@ -304,7 +304,7 @@ let integrationTests =
|
||||
use conn = Configuration.dbConn ()
|
||||
do! loadDocs ()
|
||||
|
||||
let! doc = conn.findFirstByFields<JsonDocument> SqliteDb.TableName Any [ Field.EQ "Value" "absent" ]
|
||||
let! doc = conn.findFirstByFields<JsonDocument> SqliteDb.TableName Any [ Field.Equal "Value" "absent" ]
|
||||
Expect.isNone doc "There should not have been a document returned"
|
||||
}
|
||||
]
|
||||
@@ -316,7 +316,7 @@ let integrationTests =
|
||||
|
||||
let! doc =
|
||||
conn.findFirstByFieldsOrdered<JsonDocument>
|
||||
SqliteDb.TableName Any [ Field.EQ "Sub.Foo" "green" ] [ Field.Named "Sub.Bar" ]
|
||||
SqliteDb.TableName Any [ Field.Equal "Sub.Foo" "green" ] [ Field.Named "Sub.Bar" ]
|
||||
Expect.isSome doc "There should have been a document returned"
|
||||
Expect.equal "two" doc.Value.Id "An incorrect document was returned"
|
||||
}
|
||||
@@ -327,7 +327,7 @@ let integrationTests =
|
||||
|
||||
let! doc =
|
||||
conn.findFirstByFieldsOrdered<JsonDocument>
|
||||
SqliteDb.TableName Any [ Field.EQ "Sub.Foo" "green" ] [ Field.Named "Sub.Bar DESC" ]
|
||||
SqliteDb.TableName Any [ Field.Equal "Sub.Foo" "green" ] [ Field.Named "Sub.Bar DESC" ]
|
||||
Expect.isSome doc "There should have been a document returned"
|
||||
Expect.equal "four" doc.Value.Id "An incorrect document was returned"
|
||||
}
|
||||
@@ -416,8 +416,8 @@ let integrationTests =
|
||||
use conn = Configuration.dbConn ()
|
||||
do! loadDocs ()
|
||||
|
||||
do! conn.patchByFields SqliteDb.TableName Any [ Field.EQ "Value" "purple" ] {| NumValue = 77 |}
|
||||
let! after = conn.countByFields SqliteDb.TableName Any [ Field.EQ "NumValue" 77 ]
|
||||
do! conn.patchByFields SqliteDb.TableName Any [ Field.Equal "Value" "purple" ] {| NumValue = 77 |}
|
||||
let! after = conn.countByFields SqliteDb.TableName Any [ Field.Equal "NumValue" 77 ]
|
||||
Expect.equal after 2L "There should have been 2 documents returned"
|
||||
}
|
||||
testTask "succeeds when no document is updated" {
|
||||
@@ -428,7 +428,7 @@ let integrationTests =
|
||||
Expect.isEmpty before "There should have been no documents returned"
|
||||
|
||||
// This not raising an exception is the test
|
||||
do! conn.patchByFields SqliteDb.TableName Any [ Field.EQ "Value" "burgundy" ] {| Foo = "green" |}
|
||||
do! conn.patchByFields SqliteDb.TableName Any [ Field.Equal "Value" "burgundy" ] {| Foo = "green" |}
|
||||
}
|
||||
]
|
||||
testList "removeFieldsById" [
|
||||
@@ -467,7 +467,7 @@ let integrationTests =
|
||||
use conn = Configuration.dbConn ()
|
||||
do! loadDocs ()
|
||||
|
||||
do! conn.removeFieldsByFields SqliteDb.TableName Any [ Field.EQ "NumValue" 17 ] [ "Sub" ]
|
||||
do! conn.removeFieldsByFields SqliteDb.TableName Any [ Field.Equal "NumValue" 17 ] [ "Sub" ]
|
||||
try
|
||||
let! _ = conn.findById<string, JsonDocument> SqliteDb.TableName "four"
|
||||
Expect.isTrue false "The updated document should have failed to parse"
|
||||
@@ -481,14 +481,15 @@ let integrationTests =
|
||||
do! loadDocs ()
|
||||
|
||||
// This not raising an exception is the test
|
||||
do! conn.removeFieldsByFields SqliteDb.TableName Any [ Field.EQ "NumValue" 17 ] [ "Nothing" ]
|
||||
do! conn.removeFieldsByFields SqliteDb.TableName Any [ Field.Equal "NumValue" 17 ] [ "Nothing" ]
|
||||
}
|
||||
testTask "succeeds when no document is matched" {
|
||||
use! db = SqliteDb.BuildDb()
|
||||
use conn = Configuration.dbConn ()
|
||||
|
||||
// This not raising an exception is the test
|
||||
do! conn.removeFieldsByFields SqliteDb.TableName Any [ Field.NE "Abracadabra" "apple" ] [ "Value" ]
|
||||
do! conn.removeFieldsByFields
|
||||
SqliteDb.TableName Any [ Field.NotEqual "Abracadabra" "apple" ] [ "Value" ]
|
||||
}
|
||||
]
|
||||
testList "deleteById" [
|
||||
@@ -517,7 +518,7 @@ let integrationTests =
|
||||
use conn = Configuration.dbConn ()
|
||||
do! loadDocs ()
|
||||
|
||||
do! conn.deleteByFields SqliteDb.TableName Any [ Field.NE "Value" "purple" ]
|
||||
do! conn.deleteByFields SqliteDb.TableName Any [ Field.NotEqual "Value" "purple" ]
|
||||
let! remaining = conn.countAll SqliteDb.TableName
|
||||
Expect.equal remaining 2L "There should have been 2 documents remaining"
|
||||
}
|
||||
@@ -526,7 +527,7 @@ let integrationTests =
|
||||
use conn = Configuration.dbConn ()
|
||||
do! loadDocs ()
|
||||
|
||||
do! conn.deleteByFields SqliteDb.TableName Any [ Field.EQ "Value" "crimson" ]
|
||||
do! conn.deleteByFields SqliteDb.TableName Any [ Field.Equal "Value" "crimson" ]
|
||||
let! remaining = conn.countAll SqliteDb.TableName
|
||||
Expect.equal remaining 5L "There should have been 5 documents remaining"
|
||||
}
|
||||
|
||||
@@ -15,42 +15,54 @@ open Types
|
||||
/// Unit tests for the Query module of the SQLite library
|
||||
let queryTests = testList "Query" [
|
||||
testList "whereByFields" [
|
||||
test "succeeds for a single field when a logical operator is passed" {
|
||||
test "succeeds for a single field when a logical comparison is passed" {
|
||||
Expect.equal
|
||||
(Query.whereByFields Any [ { Field.GT "theField" 0 with ParameterName = Some "@test" } ])
|
||||
(Query.whereByFields Any [ { Field.Greater "theField" 0 with ParameterName = Some "@test" } ])
|
||||
"data->>'theField' > @test"
|
||||
"WHERE clause not correct"
|
||||
}
|
||||
test "succeeds for a single field when an existence operator is passed" {
|
||||
test "succeeds for a single field when an existence comparison is passed" {
|
||||
Expect.equal
|
||||
(Query.whereByFields Any [ Field.NEX "thatField" ])
|
||||
(Query.whereByFields Any [ Field.NotExists "thatField" ])
|
||||
"data->>'thatField' IS NULL"
|
||||
"WHERE clause not correct"
|
||||
}
|
||||
test "succeeds for a single field when a between operator is passed" {
|
||||
test "succeeds for a single field when a between comparison is passed" {
|
||||
Expect.equal
|
||||
(Query.whereByFields All [ { Field.BT "aField" 50 99 with ParameterName = Some "@range" } ])
|
||||
(Query.whereByFields All [ { Field.Between "aField" 50 99 with ParameterName = Some "@range" } ])
|
||||
"data->>'aField' BETWEEN @rangemin AND @rangemax"
|
||||
"WHERE clause not correct"
|
||||
}
|
||||
test "succeeds for all multiple fields with logical operators" {
|
||||
test "succeeds for all multiple fields with logical comparisons" {
|
||||
Expect.equal
|
||||
(Query.whereByFields All [ Field.EQ "theFirst" "1"; Field.EQ "numberTwo" "2" ])
|
||||
(Query.whereByFields All [ Field.Equal "theFirst" "1"; Field.Equal "numberTwo" "2" ])
|
||||
"data->>'theFirst' = @field0 AND data->>'numberTwo' = @field1"
|
||||
"WHERE clause not correct"
|
||||
}
|
||||
test "succeeds for any multiple fields with an existence operator" {
|
||||
test "succeeds for any multiple fields with an existence comparison" {
|
||||
Expect.equal
|
||||
(Query.whereByFields Any [ Field.NEX "thatField"; Field.GE "thisField" 18 ])
|
||||
(Query.whereByFields Any [ Field.NotExists "thatField"; Field.GreaterOrEqual "thisField" 18 ])
|
||||
"data->>'thatField' IS NULL OR data->>'thisField' >= @field0"
|
||||
"WHERE clause not correct"
|
||||
}
|
||||
test "succeeds for all multiple fields with between operators" {
|
||||
test "succeeds for all multiple fields with between comparisons" {
|
||||
Expect.equal
|
||||
(Query.whereByFields All [ Field.BT "aField" 50 99; Field.BT "anotherField" "a" "b" ])
|
||||
(Query.whereByFields All [ Field.Between "aField" 50 99; Field.Between "anotherField" "a" "b" ])
|
||||
"data->>'aField' BETWEEN @field0min AND @field0max AND data->>'anotherField' BETWEEN @field1min AND @field1max"
|
||||
"WHERE clause not correct"
|
||||
}
|
||||
test "succeeds for a field with an In comparison" {
|
||||
Expect.equal
|
||||
(Query.whereByFields All [ Field.In "this" [ "a"; "b"; "c" ] ])
|
||||
"data->>'this' IN (@field0_0, @field0_1, @field0_2)"
|
||||
"WHERE clause not correct"
|
||||
}
|
||||
test "succeeds for a field with an InArray comparison" {
|
||||
Expect.equal
|
||||
(Query.whereByFields All [ Field.InArray "this" "the_table" [ "a"; "b" ] ])
|
||||
"EXISTS (SELECT 1 FROM json_each(the_table.data, '$.this') WHERE value IN (@field0_0, @field0_1))"
|
||||
"WHERE clause not correct"
|
||||
}
|
||||
]
|
||||
test "whereById succeeds" {
|
||||
Expect.equal (Query.whereById "@id") "data->>'Id' = @id" "WHERE clause not correct"
|
||||
@@ -72,7 +84,7 @@ let queryTests = testList "Query" [
|
||||
}
|
||||
test "byFields succeeds" {
|
||||
Expect.equal
|
||||
(Query.byFields "unit" Any [ Field.GT "That" 14 ])
|
||||
(Query.byFields "unit" Any [ Field.Greater "That" 14 ])
|
||||
"unit WHERE data->>'That' > @field0"
|
||||
"By-Field query not correct"
|
||||
}
|
||||
@@ -98,14 +110,14 @@ let parametersTests = testList "Parameters" [
|
||||
}
|
||||
testList "addFieldParam" [
|
||||
test "succeeds when adding a parameter" {
|
||||
let paramList = addFieldParam "@field" (Field.EQ "it" 99) []
|
||||
let paramList = addFieldParam "@field" (Field.Equal "it" 99) []
|
||||
Expect.hasLength paramList 1 "There should have been a parameter added"
|
||||
let theParam = Seq.head paramList
|
||||
Expect.equal theParam.ParameterName "@field" "The parameter name is incorrect"
|
||||
Expect.equal theParam.Value 99 "The parameter value is incorrect"
|
||||
}
|
||||
test "succeeds when not adding a parameter" {
|
||||
let paramList = addFieldParam "@it" (Field.NEX "Coffee") []
|
||||
let paramList = addFieldParam "@it" (Field.NotExists "Coffee") []
|
||||
Expect.isEmpty paramList "There should not have been any parameters added"
|
||||
}
|
||||
]
|
||||
@@ -380,14 +392,14 @@ let countTests = testList "Count" [
|
||||
use! db = SqliteDb.BuildDb()
|
||||
do! loadDocs ()
|
||||
|
||||
let! theCount = Count.byFields SqliteDb.TableName Any [ Field.BT "NumValue" 10 20 ]
|
||||
let! theCount = Count.byFields SqliteDb.TableName Any [ Field.Between "NumValue" 10 20 ]
|
||||
Expect.equal theCount 3L "There should have been 3 matching documents"
|
||||
}
|
||||
testTask "succeeds for a non-numeric range" {
|
||||
use! db = SqliteDb.BuildDb()
|
||||
do! loadDocs ()
|
||||
|
||||
let! theCount = Count.byFields SqliteDb.TableName Any [ Field.BT "Value" "aardvark" "apple" ]
|
||||
let! theCount = Count.byFields SqliteDb.TableName Any [ Field.Between "Value" "aardvark" "apple" ]
|
||||
Expect.equal theCount 1L "There should have been 1 matching document"
|
||||
}
|
||||
]
|
||||
@@ -416,14 +428,14 @@ let existsTests = testList "Exists" [
|
||||
use! db = SqliteDb.BuildDb()
|
||||
do! loadDocs ()
|
||||
|
||||
let! exists = Exists.byFields SqliteDb.TableName Any [ Field.EQ "NumValue" 10 ]
|
||||
let! exists = Exists.byFields SqliteDb.TableName Any [ Field.Equal "NumValue" 10 ]
|
||||
Expect.isTrue exists "There should have been existing documents"
|
||||
}
|
||||
testTask "succeeds when no matching documents exist" {
|
||||
use! db = SqliteDb.BuildDb()
|
||||
do! loadDocs ()
|
||||
|
||||
let! exists = Exists.byFields SqliteDb.TableName Any [ Field.LT "Nothing" "none" ]
|
||||
let! exists = Exists.byFields SqliteDb.TableName Any [ Field.Less "Nothing" "none" ]
|
||||
Expect.isFalse exists "There should not have been any existing documents"
|
||||
}
|
||||
]
|
||||
@@ -508,16 +520,43 @@ let findTests = testList "Find" [
|
||||
use! db = SqliteDb.BuildDb()
|
||||
do! loadDocs ()
|
||||
|
||||
let! docs = Find.byFields<JsonDocument> SqliteDb.TableName Any [ Field.GT "NumValue" 15 ]
|
||||
Expect.equal (List.length docs) 2 "There should have been two documents returned"
|
||||
let! docs = Find.byFields<JsonDocument> SqliteDb.TableName Any [ Field.Greater "NumValue" 15 ]
|
||||
Expect.hasLength docs 2 "There should have been two documents returned"
|
||||
}
|
||||
testTask "succeeds when documents are found using IN with numeric field" {
|
||||
use! db = SqliteDb.BuildDb()
|
||||
do! loadDocs ()
|
||||
|
||||
let! docs = Find.byFields<JsonDocument> SqliteDb.TableName All [ Field.In "NumValue" [ 2; 4; 6; 8 ] ]
|
||||
Expect.hasLength docs 1 "There should have been one document returned"
|
||||
}
|
||||
testTask "succeeds when documents are not found" {
|
||||
use! db = SqliteDb.BuildDb()
|
||||
do! loadDocs ()
|
||||
|
||||
let! docs = Find.byFields<JsonDocument> SqliteDb.TableName Any [ Field.GT "NumValue" 100 ]
|
||||
let! docs = Find.byFields<JsonDocument> SqliteDb.TableName Any [ Field.Greater "NumValue" 100 ]
|
||||
Expect.isTrue (List.isEmpty docs) "There should have been no documents returned"
|
||||
}
|
||||
testTask "succeeds for InArray when matching documents exist" {
|
||||
use! db = SqliteDb.BuildDb()
|
||||
do! Definition.ensureTable SqliteDb.TableName
|
||||
for doc in ArrayDocument.TestDocuments do do! insert SqliteDb.TableName doc
|
||||
|
||||
let! docs =
|
||||
Find.byFields<ArrayDocument>
|
||||
SqliteDb.TableName All [ Field.InArray "Values" SqliteDb.TableName [ "c" ] ]
|
||||
Expect.hasLength docs 2 "There should have been two documents returned"
|
||||
}
|
||||
testTask "succeeds for InArray when no matching documents exist" {
|
||||
use! db = SqliteDb.BuildDb()
|
||||
do! Definition.ensureTable SqliteDb.TableName
|
||||
for doc in ArrayDocument.TestDocuments do do! insert SqliteDb.TableName doc
|
||||
|
||||
let! docs =
|
||||
Find.byFields<ArrayDocument>
|
||||
SqliteDb.TableName All [ Field.InArray "Values" SqliteDb.TableName [ "j" ] ]
|
||||
Expect.isEmpty docs "There should have been no documents returned"
|
||||
}
|
||||
]
|
||||
testList "byFieldsOrdered" [
|
||||
testTask "succeeds when sorting ascending" {
|
||||
@@ -526,7 +565,7 @@ let findTests = testList "Find" [
|
||||
|
||||
let! docs =
|
||||
Find.byFieldsOrdered<JsonDocument>
|
||||
SqliteDb.TableName Any [ Field.GT "NumValue" 15 ] [ Field.Named "Id" ]
|
||||
SqliteDb.TableName Any [ Field.Greater "NumValue" 15 ] [ Field.Named "Id" ]
|
||||
Expect.hasLength docs 2 "There should have been two documents returned"
|
||||
Expect.equal
|
||||
(docs |> List.map _.Id |> String.concat "|") "five|four" "The documents were not ordered correctly"
|
||||
@@ -537,7 +576,7 @@ let findTests = testList "Find" [
|
||||
|
||||
let! docs =
|
||||
Find.byFieldsOrdered<JsonDocument>
|
||||
SqliteDb.TableName Any [ Field.GT "NumValue" 15 ] [ Field.Named "Id DESC" ]
|
||||
SqliteDb.TableName Any [ Field.Greater "NumValue" 15 ] [ Field.Named "Id DESC" ]
|
||||
Expect.hasLength docs 2 "There should have been two documents returned"
|
||||
Expect.equal
|
||||
(docs |> List.map _.Id |> String.concat "|") "four|five" "The documents were not ordered correctly"
|
||||
@@ -548,7 +587,7 @@ let findTests = testList "Find" [
|
||||
|
||||
let! docs =
|
||||
Find.byFieldsOrdered<JsonDocument>
|
||||
SqliteDb.TableName All [ Field.LE "NumValue" 10 ] [ Field.Named "Value" ]
|
||||
SqliteDb.TableName All [ Field.LessOrEqual "NumValue" 10 ] [ Field.Named "Value" ]
|
||||
Expect.hasLength docs 3 "There should have been three documents returned"
|
||||
Expect.equal
|
||||
(docs |> List.map _.Id |> String.concat "|") "three|one|two" "Documents not ordered correctly"
|
||||
@@ -559,7 +598,7 @@ let findTests = testList "Find" [
|
||||
|
||||
let! docs =
|
||||
Find.byFieldsOrdered<JsonDocument>
|
||||
SqliteDb.TableName All [ Field.LE "NumValue" 10 ] [ Field.Named "i:Value" ]
|
||||
SqliteDb.TableName All [ Field.LessOrEqual "NumValue" 10 ] [ Field.Named "i:Value" ]
|
||||
Expect.hasLength docs 3 "There should have been three documents returned"
|
||||
Expect.equal
|
||||
(docs |> List.map _.Id |> String.concat "|") "three|two|one" "Documents not ordered correctly"
|
||||
@@ -570,7 +609,7 @@ let findTests = testList "Find" [
|
||||
use! db = SqliteDb.BuildDb()
|
||||
do! loadDocs ()
|
||||
|
||||
let! doc = Find.firstByFields<JsonDocument> SqliteDb.TableName Any [ Field.EQ "Value" "another" ]
|
||||
let! doc = Find.firstByFields<JsonDocument> SqliteDb.TableName Any [ Field.Equal "Value" "another" ]
|
||||
Expect.isSome doc "There should have been a document returned"
|
||||
Expect.equal doc.Value.Id "two" "The incorrect document was returned"
|
||||
}
|
||||
@@ -578,7 +617,7 @@ let findTests = testList "Find" [
|
||||
use! db = SqliteDb.BuildDb()
|
||||
do! loadDocs ()
|
||||
|
||||
let! doc = Find.firstByFields<JsonDocument> SqliteDb.TableName Any [ Field.EQ "Sub.Foo" "green" ]
|
||||
let! doc = Find.firstByFields<JsonDocument> SqliteDb.TableName Any [ Field.Equal "Sub.Foo" "green" ]
|
||||
Expect.isSome doc "There should have been a document returned"
|
||||
Expect.contains [ "two"; "four" ] doc.Value.Id "An incorrect document was returned"
|
||||
}
|
||||
@@ -586,7 +625,7 @@ let findTests = testList "Find" [
|
||||
use! db = SqliteDb.BuildDb()
|
||||
do! loadDocs ()
|
||||
|
||||
let! doc = Find.firstByFields<JsonDocument> SqliteDb.TableName Any [ Field.EQ "Value" "absent" ]
|
||||
let! doc = Find.firstByFields<JsonDocument> SqliteDb.TableName Any [ Field.Equal "Value" "absent" ]
|
||||
Expect.isNone doc "There should not have been a document returned"
|
||||
}
|
||||
]
|
||||
@@ -597,7 +636,7 @@ let findTests = testList "Find" [
|
||||
|
||||
let! doc =
|
||||
Find.firstByFieldsOrdered<JsonDocument>
|
||||
SqliteDb.TableName Any [ Field.EQ "Sub.Foo" "green" ] [ Field.Named "Sub.Bar" ]
|
||||
SqliteDb.TableName Any [ Field.Equal "Sub.Foo" "green" ] [ Field.Named "Sub.Bar" ]
|
||||
Expect.isSome doc "There should have been a document returned"
|
||||
Expect.equal "two" doc.Value.Id "An incorrect document was returned"
|
||||
}
|
||||
@@ -607,7 +646,7 @@ let findTests = testList "Find" [
|
||||
|
||||
let! doc =
|
||||
Find.firstByFieldsOrdered<JsonDocument>
|
||||
SqliteDb.TableName Any [ Field.EQ "Sub.Foo" "green" ] [ Field.Named "Sub.Bar DESC" ]
|
||||
SqliteDb.TableName Any [ Field.Equal "Sub.Foo" "green" ] [ Field.Named "Sub.Bar DESC" ]
|
||||
Expect.isSome doc "There should have been a document returned"
|
||||
Expect.equal "four" doc.Value.Id "An incorrect document was returned"
|
||||
}
|
||||
@@ -690,8 +729,8 @@ let patchTests = testList "Patch" [
|
||||
use! db = SqliteDb.BuildDb()
|
||||
do! loadDocs ()
|
||||
|
||||
do! Patch.byFields SqliteDb.TableName Any [ Field.EQ "Value" "purple" ] {| NumValue = 77 |}
|
||||
let! after = Count.byFields SqliteDb.TableName Any [ Field.EQ "NumValue" 77 ]
|
||||
do! Patch.byFields SqliteDb.TableName Any [ Field.Equal "Value" "purple" ] {| NumValue = 77 |}
|
||||
let! after = Count.byFields SqliteDb.TableName Any [ Field.Equal "NumValue" 77 ]
|
||||
Expect.equal after 2L "There should have been 2 documents returned"
|
||||
}
|
||||
testTask "succeeds when no document is updated" {
|
||||
@@ -701,7 +740,7 @@ let patchTests = testList "Patch" [
|
||||
Expect.isEmpty before "There should have been no documents returned"
|
||||
|
||||
// This not raising an exception is the test
|
||||
do! Patch.byFields SqliteDb.TableName Any [ Field.EQ "Value" "burgundy" ] {| Foo = "green" |}
|
||||
do! Patch.byFields SqliteDb.TableName Any [ Field.Equal "Value" "burgundy" ] {| Foo = "green" |}
|
||||
}
|
||||
]
|
||||
]
|
||||
@@ -740,7 +779,7 @@ let removeFieldsTests = testList "RemoveFields" [
|
||||
use! db = SqliteDb.BuildDb()
|
||||
do! loadDocs ()
|
||||
|
||||
do! RemoveFields.byFields SqliteDb.TableName Any [ Field.EQ "NumValue" 17 ] [ "Sub" ]
|
||||
do! RemoveFields.byFields SqliteDb.TableName Any [ Field.Equal "NumValue" 17 ] [ "Sub" ]
|
||||
try
|
||||
let! _ = Find.byId<string, JsonDocument> SqliteDb.TableName "four"
|
||||
Expect.isTrue false "The updated document should have failed to parse"
|
||||
@@ -753,13 +792,13 @@ let removeFieldsTests = testList "RemoveFields" [
|
||||
do! loadDocs ()
|
||||
|
||||
// This not raising an exception is the test
|
||||
do! RemoveFields.byFields SqliteDb.TableName Any [ Field.EQ "NumValue" 17 ] [ "Nothing" ]
|
||||
do! RemoveFields.byFields SqliteDb.TableName Any [ Field.Equal "NumValue" 17 ] [ "Nothing" ]
|
||||
}
|
||||
testTask "succeeds when no document is matched" {
|
||||
use! db = SqliteDb.BuildDb()
|
||||
|
||||
// This not raising an exception is the test
|
||||
do! RemoveFields.byFields SqliteDb.TableName Any [ Field.NE "Abracadabra" "apple" ] [ "Value" ]
|
||||
do! RemoveFields.byFields SqliteDb.TableName Any [ Field.NotEqual "Abracadabra" "apple" ] [ "Value" ]
|
||||
}
|
||||
]
|
||||
]
|
||||
@@ -789,7 +828,7 @@ let deleteTests = testList "Delete" [
|
||||
use! db = SqliteDb.BuildDb()
|
||||
do! loadDocs ()
|
||||
|
||||
do! Delete.byFields SqliteDb.TableName Any [ Field.NE "Value" "purple" ]
|
||||
do! Delete.byFields SqliteDb.TableName Any [ Field.NotEqual "Value" "purple" ]
|
||||
let! remaining = Count.all SqliteDb.TableName
|
||||
Expect.equal remaining 2L "There should have been 2 documents remaining"
|
||||
}
|
||||
@@ -797,7 +836,7 @@ let deleteTests = testList "Delete" [
|
||||
use! db = SqliteDb.BuildDb()
|
||||
do! loadDocs ()
|
||||
|
||||
do! Delete.byFields SqliteDb.TableName Any [ Field.EQ "Value" "crimson" ]
|
||||
do! Delete.byFields SqliteDb.TableName Any [ Field.Equal "Value" "crimson" ]
|
||||
let! remaining = Count.all SqliteDb.TableName
|
||||
Expect.equal remaining 5L "There should have been 5 documents remaining"
|
||||
}
|
||||
|
||||
@@ -8,20 +8,32 @@ type SubDocument =
|
||||
{ Foo: string
|
||||
Bar: string }
|
||||
|
||||
type ArrayDocument =
|
||||
{ Id: string
|
||||
Values: string list }
|
||||
with
|
||||
/// <summary>
|
||||
/// A set of documents used for integration tests
|
||||
/// </summary>
|
||||
static member TestDocuments =
|
||||
[ { Id = "first"; Values = [ "a"; "b"; "c" ] }
|
||||
{ Id = "second"; Values = [ "c"; "d"; "e" ] }
|
||||
{ Id = "third"; Values = [ "x"; "y"; "z" ] } ]
|
||||
|
||||
type JsonDocument =
|
||||
{ Id: string
|
||||
Value: string
|
||||
NumValue: int
|
||||
Sub: SubDocument option }
|
||||
|
||||
|
||||
/// An empty JsonDocument
|
||||
let emptyDoc = { Id = ""; Value = ""; NumValue = 0; Sub = None }
|
||||
|
||||
/// Documents to use for testing
|
||||
let testDocuments = [
|
||||
{ Id = "one"; Value = "FIRST!"; NumValue = 0; Sub = None }
|
||||
{ Id = "two"; Value = "another"; NumValue = 10; Sub = Some { Foo = "green"; Bar = "blue" } }
|
||||
{ Id = "three"; Value = ""; NumValue = 4; Sub = None }
|
||||
{ Id = "four"; Value = "purple"; NumValue = 17; Sub = Some { Foo = "green"; Bar = "red" } }
|
||||
{ Id = "five"; Value = "purple"; NumValue = 18; Sub = None }
|
||||
]
|
||||
let testDocuments =
|
||||
[ { Id = "one"; Value = "FIRST!"; NumValue = 0; Sub = None }
|
||||
{ Id = "two"; Value = "another"; NumValue = 10; Sub = Some { Foo = "green"; Bar = "blue" } }
|
||||
{ Id = "three"; Value = ""; NumValue = 4; Sub = None }
|
||||
{ Id = "four"; Value = "purple"; NumValue = 17; Sub = Some { Foo = "green"; Bar = "red" } }
|
||||
{ Id = "five"; Value = "purple"; NumValue = 18; Sub = None } ]
|
||||
|
||||
Reference in New Issue
Block a user