aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Peter McGoron 2021-08-13 17:14:38 -0400
committerGravatar Peter McGoron 2021-08-13 17:14:38 -0400
commit87acf106bf466aeb7ad77c01cb23dd86211e985a (patch)
tree760c275058af7ef29aed14eab231b6480a195e59
parentmakedb: fix "searchtable" being refered to its old name "cache" (diff)
Use lowercase for all element names and symbols
The matching algorithm will work better when all names are normalized. For instance, a search of "iorn" will not list "iron" in the first three matches, but a search of "Iorn" will have "iron" as the first match.
-rw-r--r--makedb.ml11
1 files changed, 6 insertions, 5 deletions
diff --git a/makedb.ml b/makedb.ml
index e9adc32..6604f07 100644
--- a/makedb.ml
+++ b/makedb.ml
@@ -92,11 +92,12 @@ let makedb db json = let open Sqlite3
(* Bind each column name. In SQLite3 the leading ":" is part
of the named parameter. *)
in let prep i x =
- (match colarr.(i) with
- | "Symbol" -> symbs := (x,None)::!symbs
- | "Name" -> names := (x,None)::!names
- | _ -> ()
- );
+ let lcase = String.lowercase_ascii
+ in let x = (match colarr.(i) with
+ | "Symbol" -> symbs := (lcase x,None)::!symbs; lcase x
+ | "Name" -> names := (lcase x,None)::!names; lcase x
+ | _ -> x
+ ) in
binds stmt colarr.(i)
(if x = "" then Data.NULL else Data.TEXT x)