The SQL standard says this about NULL in Framework, 4.4.2:
[...] the null value is neither equal to any other value nor not equal to any other value – it is unknown whether or not it is equal to any given value [...]
In 4.4.3.3 it says:
A value of the Boolean data type is either true or false. The truth value of unknown is sometimes represented by the null value.
In its quirky way, it says that comparing something to the NULL values will result in NULL. Think of it this way: it is unknown if an unknown string is like foo.
There are several ways to get what you want:
Use coalesce:
WHERE coalesce(my_text_column, 'foo') LIKE 'foo%'
Use an OR:
WHERE my_text_column LIKE 'foo%' OR my_text_column IS NULL
use UNION ALL:
SELECT count(id)
FROM (SELECT id FROM public.mytable
WHERE my_text_column LIKE 'foo%'
UNION ALL
SELECT id FROM public.mytable
WHERE my_text_column IS NULL) AS subq;
Queries like that make indexing complicated.
SELECT count(id) FROM public.mytable WHERE my_text_column NOT LIKE 'foo' OR my_text_column IS NULL ;