Leklund fix distinct for pg and json