X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Focaml%2Fmetadata%2FmetadataConstraints.ml;h=952aa5a575a5ed98d725497fcb41918de92ee787;hb=5edfd170706c91c5d3a9d3522360b748a2dc034f;hp=cbeaad49d5112825ce632f122b4c7cdee1417f42;hpb=3605d724ae0b95e17e668b6e140c35ab19568bb2;p=helm.git diff --git a/helm/ocaml/metadata/metadataConstraints.ml b/helm/ocaml/metadata/metadataConstraints.ml index cbeaad49d..952aa5a57 100644 --- a/helm/ocaml/metadata/metadataConstraints.ml +++ b/helm/ocaml/metadata/metadataConstraints.ml @@ -151,6 +151,7 @@ let at_least ~(dbd:Mysql.dbd) ?concl_card ?full_card ?diff ?rating tables let (n,from,where) = List.fold_left (add_constraint tables) (0,[],[]) metadata in + let selected = if metadata = [] then count_tbl else "table0" in let (n,from,where) = add_all_constr count_tbl (n,from,where) concl_card full_card diff in @@ -158,12 +159,12 @@ let at_least ~(dbd:Mysql.dbd) ?concl_card ?full_card ?diff ?rating tables let where = String.concat " and " where in let query = match rating with - | None -> sprintf "select table0.source from %s where %s" from where + | None -> sprintf "select %s.source from %s where %s" selected from where | Some `Hits -> sprintf - ("select table0.source from %s, hits where %s" - ^^ " and hits.source = table0.source order by hits.no desc") - from where + ("select %s.source from %s, hits where %s" + ^^ " and hits.source = %s.source order by hits.no desc") + selected from where selected in prerr_endline query; let result = Mysql.exec dbd query in