From 6eeec2d6f0a17a5cce81156daa948dbbec947422 Mon Sep 17 00:00:00 2001 From: David Scott Date: Wed, 26 Jan 2011 17:39:05 +0000 Subject: [PATCH] CA-6021: rather than look up a "uuid" field to check whether an object exists, use "is_valid_ref" instead. Signed-off-by: David Scott --- ocaml/idl/ocaml_backend/gen_db_actions.ml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ocaml/idl/ocaml_backend/gen_db_actions.ml b/ocaml/idl/ocaml_backend/gen_db_actions.ml index bdd42467..ad1402c9 100644 --- a/ocaml/idl/ocaml_backend/gen_db_actions.ml +++ b/ocaml/idl/ocaml_backend/gen_db_actions.ml @@ -167,10 +167,13 @@ let look_up_related_table_and_field obj other full_name = let read_set_ref obj other full_name = (* Set(Ref t) is actually stored in the table t *) let obj', fld' = look_up_related_table_and_field obj other full_name in - Printf.sprintf "ignore (DB.read_field (*__context*) \"%s\" \"%s\" %s); List.map %s.%s (DB.read_set_ref {table=\"%s\"; return=Db_action_helper.reference; where_field=\"%s\"; where_value=%s})" - (Escaping.escape_obj obj.DT.name) "uuid" Client._self - _string_to_dm (OU.alias_of_ty (DT.Ref other)) - (Escaping.escape_obj obj') fld' Client._self + String.concat "\n" [ + Printf.sprintf "if not(DB.is_valid_ref %s)" Client._self; + Printf.sprintf "then raise (Api_errors.Server_error(Api_errors.handle_invalid, [ %s ]))" Client._self; + Printf.sprintf "else List.map %s.%s (DB.read_set_ref " _string_to_dm (OU.alias_of_ty (DT.Ref other)); + Printf.sprintf " { table = \"%s\"; return=Db_action_helper.reference; " (Escaping.escape_obj obj'); + Printf.sprintf " where_field = \"%s\"; where_value = %s })" fld' Client._self + ] let get_record (obj: obj) aux_fn_name = let body = -- 2.39.5