diff --git a/ocaml-sql/lib/render.ml b/ocaml-sql/lib/render.ml index eed402fc23..6fc6eb68dd 100644 --- a/ocaml-sql/lib/render.ml +++ b/ocaml-sql/lib/render.ml @@ -160,7 +160,9 @@ let rec pp_expr ppf = function | In_select (e, s) -> Fmt.pf ppf "(%a IN (%a))" pp_expr e pp_select s | Scalar_select s -> Fmt.pf ppf "(%a)" pp_select s | Exists s -> Fmt.pf ppf "(EXISTS (%a))" pp_select s - | Collate (e, c) -> Fmt.pf ppf "(%a COLLATE %s)" pp_expr e c + (* the collation is a name, so it is written by the renderer for one: bare + where it can be, quoted where a bare spelling would be two tokens *) + | Collate (e, c) -> Fmt.pf ppf "(%a COLLATE %a)" pp_expr e pp_ident c (* The three CURRENT_* keywords are zero-argument calls with no argument list in the grammar, so they render as the bare word: written [f()] the output would not re-parse, here or through the sqlite3 CLI. *) @@ -185,7 +187,8 @@ let rec pp_expr ppf = function | Ordered_agg (a, ob) -> Fmt.pf ppf "%a ORDER BY %a" pp_expr a (Fmt.list ~sep:pp_comma pp_order) ob | Window (a, w) -> Fmt.pf ppf "%a OVER (%a)" pp_expr a pp_window w - | Cast (e, ty) -> Fmt.pf ppf "CAST(%a AS %s)" pp_expr e ty + (* and so is the type a CAST names *) + | Cast (e, ty) -> Fmt.pf ppf "CAST(%a AS %a)" pp_expr e pp_ident ty | Case (base, branches, els) -> Fmt.pf ppf "(CASE"; (match base with None -> () | Some b -> Fmt.pf ppf " %a" pp_expr b);