请教一下关于egg-mysql中报错的问题
在数据中执行这条sql语句是没问题的
SELECT
ANY_VALUE ( t1.id ) AS id,
ANY_VALUE ( GROUP_CONCAT( CONCAT_WS( '-', t3.specification_id, t3.specification_value ) ) ) AS ids,
ANY_VALUE ( GROUP_CONCAT( CONCAT_WS( '-', t4.name, t3.specification_value ) ) ) AS specification,
ANY_VALUE ( GROUP_CONCAT( t2.goods_specification_value_id ) ) AS goods_specification_value_id
FROM
t_product t1
LEFT JOIN t_product_specification t2 ON t1.id = t2.product_id
LEFT JOIN t_goods_specification_value t3 ON t2.goods_specification_value_id = t3.id
LEFT JOIN t_dictionary t4 ON t3.specification_id = t4.id
WHERE
t1.goods_id = 5
GROUP BY
t1.id
但是拷贝到代码中执行就报错了,一直找不到原因
let productResult = await this.app.mysql.query('SELECT ANY_VALUE (t1.id) AS id,ANY_VALUE (GROUP_CONCAT(CONCAT_WS('-',t3.specification_id,t3.specification_value))) AS ids,ANY_VALUE (GROUP_CONCAT(CONCAT_WS('-',t4.name,t3.specification_value))) AS specification,ANY_VALUE (GROUP_CONCAT(t2.goods_specification_value_id)) AS goods_specification_value_id FROM t_product t1 LEFT JOIN t_product_specification t2 ON t1.id=t2.product_id LEFT JOIN t_goods_specification_value t3 ON t2.goods_specification_value_id=t3.id LEFT JOIN t_dictionary t4 ON t3.specification_id=t4.id WHERE t1.goods_id=5 GROUP BY t1.id');
let productData = this.ctx.camelize(productResult);
for (let x in productData) {
let tempData = productData[x].specification.split(',');
for (let y in tempData) {
productData[x][tempData[y].split('-')[0]] = tempData[y].split('-')[1]
}
}
最后定位到这个字符串处理函数CONCAT_WS,用了这个函数就会报错