【问题标题】:How to find out which key is conflicting when using the replaceUnique method?使用 replaceUnique 方法时如何找出哪个键冲突?
【发布时间】:2017-09-13 02:40:24
【问题描述】:

我正在使用replaceUnique method,它的返回类型为ReaderT backend m (Maybe (Unique record))。我的数据库表有两个唯一字段,如果违反唯一性,我想找出哪个键冲突。我该怎么做?

【问题讨论】:

    标签: haskell yesod haskell-persistent


    【解决方案1】:

    这可以通过以下代码实现:

    case unique of
      UniqueEmail _ -> -- email is conflicting
      UniqueDisplayName _ -> -- displayName is conflicting
    

    其中unique 是Unique record,UniqueEmail _ 和UniqueDisplayName _ 是唯一性约束。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-03-29
      • 2020-03-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-10-18
      • 2011-11-05
      • 1970-01-01
      相关资源
      最近更新 更多