Mercurial > urweb
comparison lib/basis.lig @ 223:bbe5899a9585
Queries back to working as well as before, after start of refactoring to support grouping
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Thu, 21 Aug 2008 12:49:29 -0400 |
parents | 79819a6346e2 |
children | cb8a68964ebb |
comparison
equal
deleted
inserted
replaced
222:36fef91a6bbf | 223:bbe5899a9585 |
---|---|
12 con sql_table :: {Type} -> Type | 12 con sql_table :: {Type} -> Type |
13 | 13 |
14 (*** Queries *) | 14 (*** Queries *) |
15 | 15 |
16 con sql_query :: {{Type}} -> Type | 16 con sql_query :: {{Type}} -> Type |
17 con sql_exp :: {{Type}} -> Type -> Type | 17 con sql_exp :: {{Type}} -> {{Type}} -> Type -> Type |
18 | 18 |
19 val sql_query : tables :: {({Type} * {Type})} | 19 con sql_subset :: {{Type}} -> {{Type}} -> Type |
20 -> {From : $(fold (fn nm => fn selected_unselected :: ({Type} * {Type}) => fn acc => | 20 val sql_subset : keep_drop :: {({Type} * {Type})} |
21 [nm] ~ acc => selected_unselected.1 ~ selected_unselected.2 => | 21 -> sql_subset |
22 [nm = sql_table (selected_unselected.1 ++ selected_unselected.2)] ++ acc) [] tables), | 22 (fold (fn nm => fn fields :: ({Type} * {Type}) => fn acc => |
23 Where : sql_exp (fold (fn nm => fn selected_unselected :: ({Type} * {Type}) => fn acc => | 23 [nm] ~ acc => fields.1 ~ fields.2 => |
24 [nm] ~ acc => selected_unselected.1 ~ selected_unselected.2 => | 24 [nm = fields.1 ++ fields.2] ++ acc) [] keep_drop) |
25 [nm = selected_unselected.1 ++ selected_unselected.2] ++ acc) [] tables) bool} | 25 (fold (fn nm => fn fields :: ({Type} * {Type}) => fn acc => |
26 -> sql_query (fold (fn nm => fn selected_unselected :: ({Type} * {Type}) => fn acc => [nm] ~ acc => | 26 [nm] ~ acc => |
27 [nm = selected_unselected.1] ++ acc) [] tables) | 27 [nm = fields.1] ++ acc) [] keep_drop) |
28 val sql_subset_all : tables :: {{Type}} | |
29 -> sql_subset tables tables | |
30 | |
31 val sql_query : tables ::: {{Type}} | |
32 (*-> grouped ::: {{Type}}*) | |
33 -> selected ::: {{Type}} | |
34 -> {From : $(fold (fn nm => fn fields :: {Type} => fn acc => | |
35 [nm] ~ acc => [nm = sql_table fields] ++ acc) [] tables), | |
36 Where : sql_exp tables [] bool, | |
37 (*GroupBy : sql_subset tables grouped, | |
38 Having : sql_exp grouped tables bool,*) | |
39 SelectFields : sql_subset tables selected} | |
40 -> sql_query selected | |
28 | 41 |
29 val sql_field : otherTabs ::: {{Type}} -> otherFields ::: {Type} -> fieldType ::: Type | 42 val sql_field : otherTabs ::: {{Type}} -> otherFields ::: {Type} -> fieldType ::: Type |
30 -> tab :: Name -> field :: Name | 43 -> tab :: Name -> field :: Name |
31 -> sql_exp ([tab = [field = fieldType] ++ otherFields] ++ otherTabs) fieldType | 44 -> agg ::: {{Type}} |
45 -> sql_exp ([tab = [field = fieldType] ++ otherFields] ++ otherTabs) agg fieldType | |
32 | 46 |
33 class sql_injectable | 47 class sql_injectable |
34 val sql_bool : sql_injectable bool | 48 val sql_bool : sql_injectable bool |
35 val sql_int : sql_injectable int | 49 val sql_int : sql_injectable int |
36 val sql_float : sql_injectable float | 50 val sql_float : sql_injectable float |
37 val sql_string : sql_injectable string | 51 val sql_string : sql_injectable string |
38 val sql_inject : tables ::: {{Type}} -> t ::: Type -> t -> sql_injectable t -> sql_exp tables t | 52 val sql_inject : tables ::: {{Type}} -> agg ::: {{Type}} -> t ::: Type -> t -> sql_injectable t -> sql_exp tables agg t |
39 | 53 |
40 con sql_unary :: Type -> Type -> Type | 54 con sql_unary :: Type -> Type -> Type |
41 val sql_not : sql_unary bool bool | 55 val sql_not : sql_unary bool bool |
42 val sql_unary : tables ::: {{Type}} -> arg ::: Type -> res ::: Type | 56 val sql_unary : tables ::: {{Type}} -> agg ::: {{Type}} -> arg ::: Type -> res ::: Type |
43 -> sql_unary arg res -> sql_exp tables arg -> sql_exp tables res | 57 -> sql_unary arg res -> sql_exp tables agg arg -> sql_exp tables agg res |
44 | 58 |
45 con sql_binary :: Type -> Type -> Type -> Type | 59 con sql_binary :: Type -> Type -> Type -> Type |
46 val sql_and : sql_binary bool bool bool | 60 val sql_and : sql_binary bool bool bool |
47 val sql_or : sql_binary bool bool bool | 61 val sql_or : sql_binary bool bool bool |
48 val sql_binary : tables ::: {{Type}} -> arg1 ::: Type -> arg2 ::: Type -> res ::: Type | 62 val sql_binary : tables ::: {{Type}} -> agg ::: {{Type}} -> arg1 ::: Type -> arg2 ::: Type -> res ::: Type |
49 -> sql_binary arg1 arg2 res -> sql_exp tables arg1 -> sql_exp tables arg2 -> sql_exp tables res | 63 -> sql_binary arg1 arg2 res -> sql_exp tables agg arg1 -> sql_exp tables agg arg2 -> sql_exp tables agg res |
50 | 64 |
51 type sql_comparison | 65 type sql_comparison |
52 val sql_eq : sql_comparison | 66 val sql_eq : sql_comparison |
53 val sql_ne : sql_comparison | 67 val sql_ne : sql_comparison |
54 val sql_lt : sql_comparison | 68 val sql_lt : sql_comparison |
55 val sql_le : sql_comparison | 69 val sql_le : sql_comparison |
56 val sql_gt : sql_comparison | 70 val sql_gt : sql_comparison |
57 val sql_ge : sql_comparison | 71 val sql_ge : sql_comparison |
58 val sql_comparison : sql_comparison | 72 val sql_comparison : sql_comparison |
59 -> tables ::: {{Type}} -> t ::: Type -> sql_exp tables t -> sql_exp tables t | 73 -> tables ::: {{Type}} -> agg ::: {{Type}} -> t ::: Type -> sql_exp tables agg t -> sql_exp tables agg t |
60 -> sql_injectable t -> sql_exp tables bool | 74 -> sql_injectable t -> sql_exp tables agg bool |
61 | 75 |
62 (** XML *) | 76 (** XML *) |
63 | 77 |
64 con tag :: {Type} -> {Unit} -> {Unit} -> {Type} -> {Type} -> Type | 78 con tag :: {Type} -> {Unit} -> {Unit} -> {Type} -> {Type} -> Type |
65 | 79 |