嗨,这不是一个真正的问题,我只想了解原因:
在postgres 9
this_.lastModified<=NULL
评估为真,为什么? lastModified是一个没有时区的时间戳
我认为将其解释为“this_.lastModified&lt; = 0”更合乎逻辑,如果0是最低日期且lastModified是正常日期,则应该评估为假
完整查询如下所示
select
this_.*
from Entity this_
inner join DEntity d2_ on this_.device=d2_.id
inner join u u1_ on this_.learner=u1_.userID
inner join LMEntity m3_ on this_.method=m3_.id
where u1_.userID='XXXX' and not (d2_.hardwareID='muh' and this_.timestamp='2013-08-02 00:00:00' and m3_.id=0 and this_.lastModified<=NULL)
答案 0 :(得分:5)
this_.lastModified<=NULL
始终评估为null
,在这种情况下,您的where
条款是有效的:
where u1_.userID='XXXX' and not (d2_.hardwareID='muh' and this_.timestamp='2013-08-02 00:00:00' and m3_.id=0 and null)
如果所有比较都在这里:
d2_.hardwareID='muh' and this_.timestamp='2013-08-02 00:00:00' and m3_.id=0
评估为'true',整个子句的计算结果为true:
where u1_.userID='XXXX' and not (true and null)
true and null
评估为null
where u1_.userID='XXXX' and not null
not null
评估为null
where u1_.userID='XXXX' and null
如果u1_.userID='XXXX'
等于true
,u1_.userID='XXXX' and null
评估为null
且where null
等于where false
。
总之,整个
where u1_.userID='XXXX' and not (d2_.hardwareID='muh' and this_.timestamp='2013-08-02 00:00:00' and m3_.id=0 and this_.lastModified<=NULL)
将评估为null
,如果u1_.userID='XXXX'
且所有d2_.hardwareID='muh' and this_.timestamp='2013-08-02 00:00:00' and m3_.id=0
给出true