X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Fsoftware%2Fcomponents%2Fhmysql%2FhSql.ml;h=ad2b5599373cea57a2839ab806f3c2f9b54ea5a0;hb=ce0e8e7fc59e6a1f7ed6038370bdc1de096cdc01;hp=329dd2205043bfaf97115f3ea877ae7bc8fe041d;hpb=111df95ac03f2ee21dfa2422a7f531f675b1c16d;p=helm.git diff --git a/helm/software/components/hmysql/hSql.ml b/helm/software/components/hmysql/hSql.ml index 329dd2205..ad2b55993 100644 --- a/helm/software/components/hmysql/hSql.ml +++ b/helm/software/components/hmysql/hSql.ml @@ -98,8 +98,7 @@ let exec (dbtype : dbtype) (dbd : dbd) (query : string) = debug_print (lazy ("EXEC: " ^ pp_dbtype dbtype ^ "|" ^ query)); let dbd = List.assoc dbtype dbd in wrap (mk (HSqlite3.exec query) (HMysql.exec query)) dbd - with Not_found -> - if dbtype = Legacy then Nothing else raise (Error "No ro or writable db") + with Not_found -> Nothing ;; let map result ~f = @@ -138,10 +137,13 @@ let mysql_err = function let errno dbtype dbd = wrap - (fun d -> match List.assoc dbtype d with - | Mysql dbd -> mysql_err (HMysql.errno dbd) - | Sqlite dbd -> sqlite_err (HSqlite3.errno dbd) - | FakeMySql -> assert false) + (fun d -> + try + match List.assoc dbtype d with + | Mysql dbd -> mysql_err (HMysql.errno dbd) + | Sqlite dbd -> sqlite_err (HSqlite3.errno dbd) + | FakeMySql -> assert false + with Not_found -> OK) dbd ;; @@ -150,8 +152,7 @@ let escape dbtype dbd s = match List.assoc dbtype dbd with | Mysql _ | FakeMySql -> wrap HMysql.escape s | Sqlite _ -> wrap HSqlite3.escape s - with Not_found -> - if dbtype = Legacy then s else raise (Error "No ro or writable db") + with Not_found -> s ;; let escape_string_for_like dbtype dbd = @@ -160,13 +161,15 @@ let escape_string_for_like dbtype dbd = | Mysql _ | FakeMySql -> HMysql.escape_string_for_like | Sqlite _ -> HSqlite3.escape_string_for_like with Not_found -> - if dbtype = Legacy then ("ESCAPE \"\\\"" : ('a,'b,'c,'a) format4) - else raise (Error "No ro or writable db") + ("ESCAPE \"\\\"" : ('a,'b,'c,'a) format4) ;; let isMysql dbtype dbd = wrap - (fun d -> match List.assoc dbtype d with Mysql _ -> true | _ -> false) + (fun d -> + try + match List.assoc dbtype d with Mysql _ -> true | _ -> false + with Not_found -> false) dbd ;;