Fix a rather embarrassing sqlite bug