ngbatis
ngbatis copied to clipboard
[best practice] how I handled a string function issue(spoiler: about escaping!)
带有@拼接的语句解析错误问题 在getTemplateByLoader解析模板时得到TOKEN_ERROR,具体为第11行, CONCAT( type(r) , " " , src(r) , "->" ,dst(r) , "@" , rank(r) ) as rid语法错误
>>01:59:48:词法错误(TOKEN_ERROR):" , rank(r) ) as rid
位于11行 资源:
@if ( isNotEmpty( p1.code ) ) {
MATCH (s:com)-[r:${ p1.code }]-(d:com) WHERE 1==1
@} else {
MATCH (s:com)-[r]-(d:com) WHERE 1==1
@}
@if ( isNotEmpty( p1.srcName ) ) {
AND s.com.sys_name contains '${ p1.srcName }'
@}
WITH s.com.sys_name as srcName, d.com.sys_name as dstName,properties(r).yanse as relation,
CONCAT( type(r) , " " , src(r) , "->" ,dst(r) , "@" , rank(r) ) as rid
ORDER BY srcName ${ p1.order }
RETURN count(*);
8| AND s.com.sys_name contains '${ p1.srcName }'
9| @}
10| WITH s.com.sys_name as srcName, d.com.sys_name as dstName,properties(r).yanse as relation,
11| CONCAT( type(r) , " " , src(r) , "->" ,dst(r) , "@" , rank(r) ) as rid
12| ORDER BY srcName ${ p1.order }
13|
14| RETURN count(*);
解析模板语句时,rank解析有问题。
<$0>>
if ( isNotEmpty( p1.code ) ) {
<$1>><< p1.code >><$2>>
} else {
<$3>>
}
if ( isNotEmpty( p1.srcName ) ) {
<$4>><< p1.srcName >><$5>>
}
<$6>>
" , rank(r) ) as rid
<$7>><< p1.order >><$8>>
<$9>>
哇 原来是用了定界符@,加个转义就可以了
CONCAT( type(r) , " " , src(r) , "->" ,dst(r) , "\@" , rank(r) ) as rid,