title: PostgreSQL ON CONFLICT DO UPDATE with not null column and COALESCE EXCLUDED column
body: <p>I want to perform UPSERTs with data that might contain a <code>not null</code> constraint violation but without raising an error. Instead of an error, I want the proposed row to be skipped.</p>
  
  <p>Schema:</p>
  
  <pre><code>               Table "public.appointments"
      Column   |            Type             |  Modifiers
  -------------+-----------------------------+--------------
   id          | bigint                      | not null
   location_id | bigint                      | not null
   time        | timestamp without time zone | not null
   status      | text                        | not null
  Indexes:
      "appointments_pkey" PRIMARY KEY, btree (id)
      "for_upsert" UNIQUE CONSTRAINT, btree (id, location_id)
  </code></pre>
  
  <p>Existing records:</p>
  
  <pre><code> id | location_id | status |       time         
  ----+-------------+--------+----------------------
    1 |           2 | sched  | 2017-12-15 01:10:00
    2 |           2 | sched  | 2017-12-19 01:30:00
  </code></pre>
  
  <p>Query:</p>
  
  <pre><code>INSERT INTO "objects" ("id", "location_id", "time")
    VALUES (1, 2, 'sched', '2017-10-31 19:25:00'),
           (2, 2, 'canc', NULL),
           (3, 2, 'canc', NULL)
    ON CONFLICT ON CONSTRAINT for_upsert DO UPDATE
      SET "time" = COALESCE(EXCLUDED."time", "objects"."time"),
          "status" = EXCLUDED."status"
  </code></pre>
  
  <p>When a record exists with <code>time</code> not null, I want <code>status</code> to be updated regardless of the <code>EXCLUDED."time"</code> value (that's what the COALESCE attempts to do). But if there is no existing record and a new proposed row has a null <code>time</code> I don't want the row inserted or an error to be raised.</p>