Compile union correctly for postgres

The union now are correctly compiled for postgres.