Kris Jurka <books@ejurka.com> writes:
> In the second example a string comparison is being done instead of a
> timestamp comparison. Consider this psql example:
> jurka=# select now() < 'a'::text;
> ?column?
> ----------
> t
> (1 row)
BTW, as of 8.3 this particular foot-gun will go away:
regression=# select now() < 'a'::text;
ERROR: operator does not exist: timestamp with time zone < text
LINE 1: select now() < 'a'::text;
^
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
You'll still be able to force a textual comparison if you really want
one:
regression=# select now()::text < 'a'::text;
?column?
----------
t
(1 row)
but it won't happen silently.
regards, tom lane