Shouldn't the values be decoded before inserting? You solution "fixes" it while they are already inserted.