24 Feb '14, 6pm

Avoid the Three-state Boolean Problem

Avoid the Three-state Boolean Problem Gabe Berke-Williams February 24, 2014 postgres Quick, what's wrong with this Rails migration? add_column :users, :admin, :boolean Yep - it can be null. Your Boolean column is supposed to be only true or false . But now you're in the madness of three-state Booleans: it can be true , false , or NULL . Why to avoid NULL in Boolean columns Boolean logic breaks down when dealing with NULLs. This StackOverflow answer answer goes into detail. For example: true AND NULL is NULL (not false ) true AND NULL OR false is NULL Fortunately, it's easy to fix. NOT NULL Adding a NOT NULL constraint means that you'll never wonder whether a NULL value means that the user is not an admin, or whether it was never set. Let's add the constraint: add_column :users, :admin, :boolean, null: false But now the migration doesn't run. Set a default value The NOT NUL...

Full article: http://robots.thoughtbot.com/avoid-the-threestate-boolean...

Tweets

Standards help companies deal with the problem ...

newelectronics.co.uk 25 Feb '14, 12am

And these measures are being codified into standards, with the SAE – the US-based standards organisation - and the Interna...

Dot Earth Blog: Can California Avoid a ‘Shock t...

dotearth.blogs.nytimes.com 23 Feb '14, 5pm

Robyn Beck/Agence France-Presse — Getty Images A sign over a highway in California. Forecasters predict heavy rains will s...

"Boys will be boys?"

kateelliottsff.tumblr.com 24 Feb '14, 11am

For months, every morning when my daughter was in preschool, I watched her construct an elaborate castle out of blocks, co...

Can California Avoid a ‘Shock to Trance’ Approa...

dotearth.blogs.nytimes.com 23 Feb '14, 4pm

Robyn Beck/Agence France-Presse — Getty Images A sign over a highway in California. Forecasters predict heavy rains will s...

(Karen Cheng) Three Modern Classics @karencheng #fashion #perth

(Karen Cheng) Three Modern Classics @karencheng...

karencheng.com.au 24 Feb '14, 3am

I want to share three modern classic pieces from my wardrobe, that always make me feel fabulous whenever I wear them. Vers...

20 toxic ingredients to avoid when buying body care products and cosmetics

20 toxic ingredients to avoid when buying body ...

treehugger.com 25 Feb '14, 1pm

Labels on cosmetics and body care products are a tough code to crack. The industry is so shockingly unregulated that it’s ...