我有一个简单的密码查询,想要用参数修改它。
MATCH (u:User) WHERE u.email = {searchString} return u ORDER BY {sortField} {sortOrder} SKIP {skipNumber} LIMIT {limitNumber}
执行此查询会导致以下错误:
Invalid input '{': expected whitespace, comment, '.', node labels, '[', "=~", IN, STARTS, ENDS, CONTAINS, IS, '^', '*', '/', '%', '+', '-', '=', "<>", "!=", '<', '>', "<=", ">=", AND, XOR, OR, DESCENDING, DESC, ASCENDING, ASC, ',', SKIP, LIMIT, LOAD CSV, START, MATCH, UNWIND, MERGE, CREATE, SET, DELETE, REMOVE, FOREACH, WITH, CALL, RETURN, UNION, ';' or end of input (line 1, column 87 (offset: 86)) "MATCH (lc:LeadContact) WHERE lc.email = {searchString} return lc ORDER BY {sortField} {sortOrder} SKIP {skipNumber} LIMIT {limitNumber}"
如果我删除“{sortField} {sortOrder}”并编写静态文本(例如,“通过u.name ASC订购”,则查询会顺利执行:
MATCH (u:User) WHERE u.email = {searchString} return u ORDER BY u.name ASC SKIP {skipNumber} LIMIT {limitNumber}
为什么cypher不允许这里的参数?或者我做错了什么?
答案 0 :(得分:1)
不同的ORDER BY
或方向可能需要不同的查询计划。目前,您只能参数化对查询计划没有影响的内容。由于标签和关系类型不可参数化的原因相同。