title: conditional updating in postgreSQL
body: <p>I'm testing some conditional rendering to see if it behaves as expected on a small scale before implementing it on a larger table.</p>
  
  <p>The goal is to create an update query that will only update the columns that a user has input new data in and if there is no data then nothing is done to those columns</p>
  
  <p>here's my case when then test. The row with the null value was not updated 'newValue'</p>
  
  <pre><code>drop table if exists tester
  
  create table tester (
  id serial primary key
  val TEXT,
  )
  
  insert into tester (val) values (null)
  
  select * from tester
  
  update tester 
  set val = case 
  when val = null 
  then 'newValue' 
  else val 
  end;
  </code></pre>
  
  <p>Here's a simple example of what I want to produce ($1 is the user input)</p>
  
  <pre><code>drop table if exists tester
  
  create table tester (
  id serial primary key
  val TEXT,
  )
  
  insert into tester (val) values (null)
  
  select * from tester
  
  update tester 
  set val = case 
  when val != $1
  then $1 
  else val end
  where id = 1
  </code></pre>
  
  <p>what I'm expecting to happen is the insert to create a row with the id of 1 and a val cell that equals null.</p>
  
  <p>Then in the update query, I'm thinking the update will check if the stored data in val on row 1 is NOT equal to the input value, if that is true then the input value will get set to val for row 1.</p>
  
  <p>Is that logic and syntax correct? If not, what is incorrect? Thanks!</p>