我正在构建一个Web应用程序,我注意到我的一个查询返回的是null
,而我期望的是boolean
.然而,数据库显示它实际上返回的是boolean
.
我可以在documentation中看到,Postgres认为NULL
是一个未知的布尔值.我搞不懂为什么<=
运算符会返回t
/NULL
,而不是t
/f
.
select version();
version |
---|
PostgreSQL 13.13 (Debian 13.13-0+deb11u1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit |
SELECT a.email_verified_at <= NOW() AS "emailVerified",
pg_typeof(a.email_verified_at <= NOW()) AS "emailVerifiedType",
pg_typeof((a.email_verified_at <= NOW())::boolean) AS "emailVerifiedType2"
FROM profiles AS p
INNER JOIN accounts AS a ON p.id = a.profile_id;
emailVerified | emailVerifiedType | emailVerifiedType2 |
---|---|---|
boolean | boolean | |
t | boolean | boolean |
boolean | boolean |
我如何告诉Postgres将显式的t
/f
返回给我的应用程序?