dbfix - fix typo and close another possible inconsistency
This patch fixes a typo in one request producing a SQL error.
It also close an issue where param_values could point to
inexistant param_names after the deduplications of those.
It does this by rewriting the param_values to point to the
highest id of the param_names of the same name.
The same operation is performed on the tags.
Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>