aboutsummaryrefslogtreecommitdiff
path: root/lib/ast_types.ml
diff options
context:
space:
mode:
authorMarc Coquand <marc@mccd.space>2023-12-26 15:33:05 -0600
committerMarc Coquand <marc@mccd.space>2023-12-26 15:33:05 -0600
commit508c7c9b34a892d74d087f1ef5d54d16fa000551 (patch)
tree2cbb67e75831919db1d91beabde8219900dfe0d4 /lib/ast_types.ml
parent05c3cef84ea4e69c5eeb0ee4a342b0cfc65e0f0c (diff)
downloadfixgen-508c7c9b34a892d74d087f1ef5d54d16fa000551.tar.gz
fixgen-508c7c9b34a892d74d087f1ef5d54d16fa000551.tar.bz2
fixgen-508c7c9b34a892d74d087f1ef5d54d16fa000551.zip
JSON support type handling
Diffstat (limited to 'lib/ast_types.ml')
-rw-r--r--lib/ast_types.ml16
1 files changed, 8 insertions, 8 deletions
diff --git a/lib/ast_types.ml b/lib/ast_types.ml
index 7189db7..2a786f7 100644
--- a/lib/ast_types.ml
+++ b/lib/ast_types.ml
@@ -54,11 +54,11 @@ let rec print = function
type ast_row_relation =
| PColumn of Fixture.t
- | CColumn of (string * string * (string list -> Fixture.t))
+ | CColumn of (string * string * (Fixture.compiled list -> Fixture.t))
type ast_table_relation =
| PTable of string * int * Fixture.t list
- | CTable of (string * string) list * string * int * (string -> string list -> Fixture.t list)
+ | CTable of (string * string) list * string * int * (Fixture.compiled -> Fixture.compiled list -> Fixture.t list)
(** parent (name, referenced id), row, child_name, fixture builder given a parent name and list of options *)
(* TODO: Support multiple relations *)
@@ -97,17 +97,17 @@ let extend_table_with_row table row =
| CColumn (p,pr, f) ->
(match table with
| PTable (n, amount, l_p) -> CTable ([(p,pr)], n, amount, fun p' l ->
- if p' = p then
+ if p' = Fixture.String p then
f l :: l_p
else
[]
)
| CTable (parents,c, amount, resolve_parents) ->
- let new_resolver = fun requested_parent l ->
- if requested_parent = p then
+ let new_resolver = fun (requested_parent : Fixture.compiled) l ->
+ if requested_parent = Fixture.String p then
[f l]
else
- resolve_parents requested_parent l
+ resolve_parents requested_parent l
in
CTable ((p,pr) :: parents, c, amount, new_resolver)
)
@@ -173,7 +173,7 @@ let rec resolve_fixtures tables name =
| None -> failwith ("Could not find table " ^ name)
and resolve_along_with_parents tables name amount parents c create_fixtures =
let maybe_parents_fixtures = parents
- |> List.map (fun (p,pr) -> (p,pr, resolve_fixtures tables p |> snd))
+ |> List.map (fun (p,pr) -> (Fixture.String p,pr, resolve_fixtures tables p |> snd))
|> List.map (fun (p,pr,parent_fixtures) -> (
Fixture.find_entries_for_header parent_fixtures pr
|> Result.map (fun ids -> create_fixtures p ids))
@@ -196,7 +196,7 @@ let%test "resolve_fixtures" =
let (_, user_fixtures) = resolve_fixtures tables "user" in
let (_, purchase_fixtures) = resolve_fixtures tables "posts" in
match (user_fixtures,purchase_fixtures) with
- | ([["id";_];[u;_]], [["user_id"]; [v]]) -> v = u
+ | ([[Fixture.String "id";_];[u;_]], [[Fixture.String "user_id"]; [v]]) -> v = u
| _ ->
false