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:
@@ -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"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user