Anorm 多值支持不起作用

Anorm multi-value support doesn't work

我在 Anorm 的多值支持方面遇到了这个奇怪的问题,当我使用 documentation 中所写的 Seq 时,我的查询没有 return 任何东西。这是我的查询:

控制器

def checkStock(data: Recap): Boolean =  DB.withConnection { implicit conn =>
    var so_id_list: Set[String] = Set()
    for(ls <- data.recap_items){
        for(rs <- ls.invoice_items){
            so_id_list = so_id_list ++ Set(rs.id.toString)
        }
    }
    breakable{
        play.api.Logger.info(so_id_list.toSeq.toString)
        //return ArrayBuffer(4, 5)
        val result = Sales_Order.getSO_detailbyIDlist(so_id_list.toSeq)
        play.api.Logger.info(result.toString)
        //return List()
    }
}

型号

def getSO_detailbyIDlist(so_id_list: Seq[String]):List[SO_detail] = DB.withConnection{ implicit c =>
    SQL("""SELECT detailso.sur_key, detailso.so_id AS so_id, detailso.product_id, detailso.qty, product.name, detailso.unit_name, detailso.unit_multiplier, detailso.price, detailso.discount, detailso.contract, COALESCE(rs.left_qty, 0) AS left_qty
        FROM detailso
        LEFT JOIN product ON detailso.product_id = product.id
        LEFT JOIN (SELECT Product.id, COALESCE(SUM(StockCard.left_qty), 0) as left_qty
                  FROM Warehouse_Product
                  LEFT JOIN Product ON Product.id = Warehouse_Product.product_id
                  LEFT JOIN Warehouse ON Warehouse.id = Warehouse_Product.warehouse_id
                  LEFT JOIN StockCard ON Stockcard.warehouse_product_id = Warehouse_Product.id
                  WHERE Warehouse.id = '110' AND StockCard.status = 1
                  GROUP BY id) rs ON rs.id = product.id
        WHERE detailso.so_id IN ({so_id_list})
        GROUP BY detailso.sur_key""").on('so_id_list -> so_id_list).as(SO_detailParser *)
}

如果我将 IN 查询更改为手动查询 IN (4,5),那么它 return 会按预期进行。知道为什么我的多值不起作用吗??

您可以将 Anorm 升级到具有此功能的 2.3,方法是从您的 SBT 项目中删除 Play 提供的依赖常量 anorm,并添加完全 qualified/standalone 依赖。

libraryDependencies ++= Seq( "com.typesafe.play" %% "anorm" % "2.3.7")
//2.3.7 is just an example, you can change it to any other version