This set me back for a long time, puzzled by why the entirely wrong record was returned:
SELECT *
FROM bookkeeping
WHERE category = 'Food'
AND "our description" NOT LIKE 'Online ordering%'
ORDER BY timestamp DESC
LIMIT 1;
Only by sheer chance did I try this (which made it work):
SELECT *
FROM bookkeeping
WHERE category = 'Food'
AND ("our description" NOT LIKE 'Online ordering%' OR "our description" IS NULL)
ORDER BY timestamp DESC
LIMIT 1;
You see, the "our description" text field was null for the record I expected, and for some reason, this makes PG not even consider it for "NOT LIKE", even though a NULL column obviously is "not like" 'Online ordering%'
.
I assume that this is yet another "by design" thing? However, it seems completely bizarre to me, and I keep running into similar issues where it just seems like the developers/designers just didn't think things through. (But I'm sure they did and probably considered something that I'm not aware of.)
It's too late for me at this point to ever switch databases, and I'm sure nothing better exists out there anyway, but sometimes it feels like PostgreSQL and I are fundamentally incompatible in how we think.