Resolving bad data type insertion...

...that reported in #2100. Now it's fine with pgsql and no mixed data has been inserted in sqlite but I'm not sure about the solution. @bobdenotter please check this out 'cause I'm not really enlightened with that part of the code.