-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathTestStaticRowCount.fs
72 lines (63 loc) · 1.56 KB
/
TestStaticRowCount.fs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
module Rezoom.SQL.Test.TestStaticRowCount
open System
open NUnit.Framework
open FsUnit
open Rezoom.SQL.Compiler
open Rezoom.SQL.Mapping
let private resultSets expected sql =
let userModel = userModel1()
let effect = CommandEffect.OfSQL(userModel.Model, "anonymous", sql)
let resultSet = effect.ResultSets() |> Seq.exactlyOne
Assert.AreEqual(expected, resultSet.StaticRowCount)
[<Test>]
let ``single select 1`` () =
resultSets (Some 1)
"""
select 1 as x;
"""
[<Test>]
let ``single select 2 union alled`` () =
resultSets (Some 2)
"""
select 1 as x
union all
select 2;
"""
[<Test>]
let ``single select 1 unioned`` () =
resultSets None
"""
select 1 as x
union
select 2;
"""
[<Test>]
let ``select from`` () =
resultSets None
"""
select 1 as x
from Users
"""
[<Test>]
let ``select from unioned`` () =
resultSets None
"""
select 1 as x
union all
select 1 as x
from Users;
"""
[<Test>]
let ``select from select`` () =
resultSets None
// even though this could be 1, we play it safe and say None, since there could be a where etc.
// in the subquery
"""select 1 as x from (select 1 as y) q"""
[<Test>]
let ``select 1 with where`` () =
resultSets None
"""select 1 as x where false"""
[<Test>]
let ``select 1 with limit`` () =
resultSets None
"""select 1 as x limit 0"""