esqueleto: outer join 不编译

esqueleto: outer join doesn't compile

这是我的模型的一个子集:

ServerWebsite
    desc Text
    url Text
    text Text
    username Text
    password Password
    serverDatabaseId ServerDatabaseId Maybe
    groupName Text Maybe
    serverId ServerId
    deriving Show Typeable
ServerDatabase
    desc Text
    name Text
    text Text
    username Text
    password Password
    groupName Text Maybe
    serverId ServerId
    deriving Show Typeable

我无法构建此查询:

filterServerWebsites :: SqlExpr (Value Text) -> SqlPersistM [Entity ServerWebsite]
filterServerWebsites query = select $ from $ \(w `LeftOuterJoin` db) -> do
    on (w ^. ServerWebsiteServerDatabaseId ==. db ?. ServerDatabaseId)
    where_ ((w ^. ServerWebsiteDesc `like` query)
        ||. (w ^. ServerWebsiteUrl `like` query)
        ||. (w ^. ServerWebsiteText `like` query)
        ||. (db ?. ServerDatabaseDesc `like` just query))
    return w

我不明白构建错误:

    • Couldn't match expected type ‘SqlQuery a1’
                  with actual type ‘(a0 -> b0) -> a0 -> a0 -> c0’
    • Probable cause: ‘on’ is applied to too few arguments
      In a stmt of a 'do' block:
        on (w ^. ServerWebsiteServerDatabaseId ==. db ?. ServerDatabaseId)

和:

    • Couldn't match expected type ‘b0 -> b0 -> c0’
                  with actual type ‘SqlExpr (Value Bool)’
    • Possible cause: ‘(==.)’ is applied to too many arguments
      In the first argument of ‘on’, namely
        ‘(w ^. ServerWebsiteServerDatabaseId ==. db ?. ServerDatabaseId)’

我不明白我哪里错了?

编辑 我是从这段代码开始的,它确实有效:

filterServerWebsites :: SqlExpr (Value Text) -> SqlPersistM [Entity ServerWebsite]
filterServerWebsites query = select $ from $ \w -> do
    where_ ((w ^. ServerWebsiteDesc `like` query)
        ||. (w ^. ServerWebsiteUrl `like` query)
        ||. (w ^. ServerWebsiteText `like` query))
    return w

对。所以真的是我自己的愚蠢。我应该做一个示例项目来重现这个问题,然后我就会发现这个问题。

问题是我在文件的顶部...

import Database.Esqueleto hiding (on)
import Data.Function

...因为我在 Data.Function.

文件中的其他地方使用 on

我把它改成...

import Database.Esqueleto
import qualified Data.Function as F

现在一切正常...