# HG changeset patch # User Jonathan Davies # Date 1268150522 0 # Node ID ee00783cffb3f9523a1bc12695229d3bd1a84f14 # Parent 5181c070835e08622edd6d663db8fe4ad97544ae Remove some redundant code from the Db_action_helper module and simplify the usage of this module in the auto-generated code. Signed-off-by: Jonathan Davies diff -r 5181c070835e -r ee00783cffb3 ocaml/database/db_action_helper.ml --- a/ocaml/database/db_action_helper.ml Tue Mar 09 16:02:01 2010 +0000 +++ b/ocaml/database/db_action_helper.ml Tue Mar 09 16:02:02 2010 +0000 @@ -11,20 +11,12 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. *) -(** Helper functions called from the generated Db_action code. *) - -exception Cannot_read_schema_version (** Table column name which contains the reference *) let reference = Escaping.reference (** Table column name which contains the uuid *) let uuid = "uuid" - -open Threadext - -module D = Debug.Debugger(struct let name = "sql" end) -open D (* General DB utils *) @@ -37,18 +29,6 @@ | None -> () | Some f -> f ?snapshot ty op ref -(* Return query used by update *) -let update_query tbl fldvalue fld objref = - let sql = Printf.sprintf "UPDATE %s SET %s=? WHERE %s=?;" tbl fld reference in - let params = [fldvalue; objref ] in - (sql,params) - -(* Return query used by delete *) -let deleterow_query tbl objref = - let sql = Printf.sprintf "DELETE FROM %s WHERE %s=?;" tbl reference in - let params = [ objref ] in - (sql,params) - exception Db_set_or_map_parse_fail of string let parse_sexpr s : SExpr.t list = diff -r 5181c070835e -r ee00783cffb3 ocaml/idl/ocaml_backend/gen_db_actions.ml --- a/ocaml/idl/ocaml_backend/gen_db_actions.ml Tue Mar 09 16:02:01 2010 +0000 +++ b/ocaml/idl/ocaml_backend/gen_db_actions.ml Tue Mar 09 16:02:02 2010 +0000 @@ -166,7 +166,7 @@ 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 (read_field __context \"%s\" \"%s\" %s); List.map %s.%s (read_set_ref {table=\"%s\"; return=reference; where_field=\"%s\"; where_value=%s})" + Printf.sprintf "ignore (read_field __context \"%s\" \"%s\" %s); List.map %s.%s (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 @@ -449,7 +449,6 @@ O.Module.make ~name:_db_action ~preamble:[ - "open Db_action_helper"; "open Db_cache.DBCache"; "open Db_cache_types"; "module D=Debug.Debugger(struct let name=\"db\" end)";