Fixed a bug in db_query_as_dict