Fix sum of boolean fields for postgresql