grails拼接sql语句传参问题(仅记录及警示)
def sqld="""SELECT m.project_id,w.contract_amount,w.percentage,m.have_pro_payment
from biz_invoice_wfl w
right join biz_project_main m on m.project_id=w.project_id and w.wfl_no=?
where m.project_id in( ${proListstr} )"""
def rows=sql.rows(sqld,[wflNo])
第一段混合传参方式有效
def sqld2="""SELECT m.project_id,w.contract_amount,w.percentage,m.have_pro_payment
from biz_invoice_wfl w
right join biz_project_main m on m.project_id=w.project_id and w.wfl_no='${wflNo}'
where m.project_id in( ${proListstr} )"""
def rows2=sql.rows(sqld2)
但是第二段无法得出结果
两段经过拼接的语句完全相同
均为
SELECT m.project_id,w.contract_amount,w.percentage,m.have_pro_payment
from biz_invoice_wfl w
right join biz_project_main m on m.project_id=w.project_id and w.wfl_no=‘19971119’
where m.project_id in(‘85aa6549-ca84-466e-8dfa-437e8443f5f6’)
可以看到两个结果集大小一个为0,一个为1
原因不明,故记录以加深记忆,如有能理解原理的,望解惑,感激不尽