I have a fixture with values like this:
product_four:
     id: 4
     application_id: 1
     title: "oldtitle"
     deleted_at: ~
Setting up a postgresql database for testing. But I can't figure out how to set the deleted_at field to NULL rather than [empty]. I've tried:
deleted_at: :null
deleted_at: <%= nil %>
deleted_at: ~
deleted_at: NULL
And probably a couple more, without luck. Clues for the clueless?
Just leave the value out:
product_four:
     id: 4
     application_id: 1
     title: "oldtitle"
     deleted_at:
For example:
> {:k => ''}.to_yaml
 => "--- \n:k: \"\"\n" 
> {:k => nil}.to_yaml
 => "--- \n:k: \n" 
> YAML.load({:k => nil}.to_yaml)
 => {:k=>nil} 
Note that k: means that k has a nil value whereas k: "" means that k has an empty string as its value.
You could also use an explicit null if all your parsers are aware of the latest YAML spec:
product_four:
     id: 4
     application_id: 1
     title: "oldtitle"
     deleted_at: null
For example:
> YAML.load("--- \n:k: null\n")
 => {:k=>nil} 
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With