>main :: IO()
main = withPostgresqlConn "host=localhost user=Rocko port=5432 dbname=Rocko" $ runSqlConn $ do
runMigration migrateAll
let compDay = C.fromGregorian 2011 11 21
match <- selectList
[TestStartDate ==. compDay,
TestEstimatedEnd ==. compDay,
TestStatus /<-. [Passed,Failed]] []
scheduled <- selectList [TestStatus ==. Scheduled] []
-- liftIO $ print scheduled
liftIO $ print match
if (L.null match == True) then (liftIO $ print "date available!!!! ") else (liftIO $ print "date not available")
return()
我想確定一個特定的日是否符合這個標準:不等於TestStartDate,不等於TestEstimatedEnd,並且通過不失敗是TestStatus的成員。我的邏輯有什麼問題?
但是,我想證明我選擇的日期(應該在TestEstimatedEnd上有一個匹配項)不能做正確的事情。它應該說,:日期不可用。那麼我的邏輯有什麼問題?
> id | firmware | version | startDate | estimatedEnd | status
>----+---------------------------+------------+------------+--------------+-----------
>1 | BCC Admin | 0.0.00.001 | 2011-11-19 | 2011-11-21 | Scheduled
>ghcifoo> main
"date available!!!! "
澄清:是否應該說沒有匹配日期的日期是可用的? – ivanm
是的,這就是我想要做的。 –
selectList中的條件是否連接(&&)或分離(||)? –