Fix SQL preparations