Fixes JSON distinct in postgres