Skip to content

Commit

Permalink
Merge branch '1.1.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
Thorium committed Apr 14, 2021
2 parents f7caeae + 482a262 commit 1c6ec72
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/SQLProvider.Runtime/SqlRuntime.Patterns.fs
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,20 @@ let (|AndAlsoOrElse|_|) (e:Expression) =
| ExpressionType.AndAlso, ( :? BinaryExpression as be) -> Some(be.Left,be.Right)
| _ -> None

let (|OptionIsSome|_|) = function
let (|OptionIsSome|_|) : Expression -> _ = function
| MethodCall(None,MethodWithName("get_IsSome"), [e] ) -> Some e
| :? UnaryExpression as ue when ue.NodeType = ExpressionType.Not ->
match ue.Operand with
| MethodCall(None,MethodWithName("get_IsNone"), [e] ) -> Some e
| _ -> None
| _ -> None

let (|OptionIsNone|_|) = function
let (|OptionIsNone|_|) : Expression -> _ = function
| MethodCall(None,MethodWithName("get_IsNone"), [e] ) -> Some e
| :? UnaryExpression as ue when ue.NodeType = ExpressionType.Not ->
match ue.Operand with
| MethodCall(None,MethodWithName("get_IsSome"), [e] ) -> Some e
| _ -> None
| _ -> None

let (|SqlCondOp|_|) (e:Expression) =
Expand Down
30 changes: 30 additions & 0 deletions tests/SqlProvider.Tests/QueryTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1859,6 +1859,18 @@ let ``simple select with contains query with where boolean option type``() =
}
Assert.IsTrue(qry)

[<Test>]
let ``simple select with contains query with where not boolean option type``() =
let dc = sqlOption.GetDataContext()
let qry =
query {
for cust in dc.Main.Customers do
where (not(cust.City.IsNone))
select cust.CustomerId
contains "ALFKI"
}
Assert.IsTrue(qry)

[<Test>]
let ``simple select with where boolean option types``() =
let dc = sqlOption.GetDataContext()
Expand Down Expand Up @@ -2245,6 +2257,24 @@ let ``simple select with subquery exists subquery``() =
Assert.AreEqual(91, qry.Count())
CollectionAssert.Contains(qry, "QUEEN")

[<Test; Ignore("Not supported")>]
let ``simple select with join subqry``() =
let dc = sql.GetDataContext()
let subqry =
query {
for cust2 in dc.Main.Customers do
select cust2
}
let qry =
query {
for cust in dc.Main.Customers do
join cust2 in subqry on (cust.CustomerId = cust2.CustomerId)
select (cust, cust2)
} |> Seq.toList
Assert.IsNotEmpty(qry)
Assert.AreEqual(91, qry.Count())
CollectionAssert.Contains(qry, "QUEEN")

[<Test>]
let ``simple select with subquery exists parameter from main query``() =
let dc = sql.GetDataContext()
Expand Down

0 comments on commit 1c6ec72

Please sign in to comment.