dev-resources.site
for different kinds of informations.
The most painful reason NULLs are evil
Published at
5/31/2024
Categories
rails
null
Author
epigene
Author
7 person written this
epigene
open
I keep harping on about doing null: false
everywhere, especially for strings and booleans, but sometimes there are sneaky exceptions for number fields, where a default of 0
does not make sense and the values will not be available for a time, some draft records etc.
You have to be extremely careful then because apparently NULLs are not "not equal" to anything. What do I mean?
Consider these User
records:
id: 1, age: 20
id: 2, age: 25
id: 3, age: nil
How would you query for all users who are not 20?
where.not(age: 20)
, right? Sorry to say, but User#3 will be omitted from such queries. 😫
You have two options:
- denullify the age column (may be impossible)
- tweak the query to handle the silly null edge-case:
where.not(age: 20).or(where(age: nil))
null Article's
30 articles in total
How Imburse Payments Ships High-Quality APIs Faster
read article
Need to Verify Your JSON Schema? Here's a Few Ways to Do It!
read article
Code Smell 260 - Crowdstrike NULL
read article
Be careful when using NULL in PostgreSQL
read article
The most painful reason NULLs are evil
currently reading
Null or Nothing? Unmasking the Mystery of Parameters in Dart
read article
La Solución del Billón de Dólares
read article
11 Lessons to learn when using NULLs in PostgreSQL®
read article
NULLs Are Not The Same – A Guide
read article
the (not so big) Bang!
read article
Rust's Option type... in Python
read article
Understanding Nullable Reference Types in C#
read article
Working with NULL in Databases. Turn Your Frustration Into Delight
read article
TypeScript: The many types of nothing
read article
ERROR: null" or "null pointer exception while invoking FlowService - Storage get operation
read article
ServiceNow: 1 thing for safer GlideRecord scripts
read article
How NullPointerException can be avoided in Java
read article
Consider these facts when dealing with NULL in RDBMS
read article
Unhandled Exception: type 'Null' is not a subtype of type 'int' in type cast error when trying to call function with no int
read article
When <nil> is not <nil>
read article
Absence of null in Solidity
read article
How to Check for Null in Javascript
read article
Javascript Tagalog - Null
read article
Kotlin 基礎 Part 1 -- !! や ?: と ?.let で Nullable な値を処理する
read article
Remove null check, use the Optional
read article
Handling null: optional and nullable types
read article
More JS Concepts
read article
Valores null e undefined no JavaScript
read article
Javascript default parameter for null and undefined
read article
How I Learned to Stop Worrying and Love NULL in SQL
read article
Featured ones: