动态设置集合时出错

时间:2016-07-24 10:31:39

标签: arangodb

Blow代码是对https://www.arangodb.com/tutorials/tutorial-python/

的微小修改
doc = {"_key": 'some_nice_key', "name": 'Robert', "age": '56'}
bindVars = {"doc": doc,"collection":"test"}
aql = "INSERT @doc INTO @collection LET newDoc = NEW RETURN newDoc"
queryResult = db.AQLQuery(aql, bindVars = bindVars)

,我刚做了一些修改:

{"doc": doc}  -> {"doc": doc,"collection":"test"}
INSERT @doc INTO users... -> INSERT @doc INTO @collection...

它给了我错误:

bind parameter 'bind parameter 'collection' has an invalid value or type near '@collection LET newDoc = NEW RET...' at position 1:18' has an invalid value or type (while parsing). Errors: {u'code': 400, u'errorNum': 1553, u'errorMessage': u"bind parameter 'bind parameter 'collection' has an invalid value or type near '@collection LET newDoc = NEW RET...' at position 1:18' has an invalid value or type (while parsing)", u'error': True}

没有aql动态支持集合集合或我犯了什么错误?

1 个答案:

答案 0 :(得分:2)

AQL支持注入集合名称。但这是一个特殊情况,你必须使用额外的[root@linpubn218 postgres]# journalctl -xe Jul 25 14:39:21 linpubn218.gl.avaya.com yum[29260]: Installed: postgresql84-libs-8.4.17-1PGDG.rhel6.x86_64 Jul 25 14:39:45 linpubn218.gl.avaya.com yum[29275]: Installed: postgresql84-8.4.17-1PGDG.rhel6.x86_64 Jul 25 14:40:01 linpubn218.gl.avaya.com useradd[29316]: failed adding user 'postgres', exit code: 9 Jul 25 14:40:02 linpubn218.gl.avaya.com CROND[29320]: (root) CMD (/usr/lib64/sa/sa1 1 1) Jul 25 14:40:02 linpubn218.gl.avaya.com systemd[1]: Reloading. Jul 25 14:40:03 linpubn218.gl.avaya.com systemd[1]: Configuration file /usr/lib/systemd/system/auditd.service is marked world-inaccessible. This has no effect as config Jul 25 14:40:03 linpubn218.gl.avaya.com yum[29309]: Installed: postgresql84-server-8.4.17-1PGDG.rhel6.x86_64 Jul 25 14:42:05 linpubn218.gl.avaya.com polkitd[819]: Registered Authentication Agent for unix-process:29459:43987285 (system bus name :1.292 [/usr/bin/pkttyagent --not Jul 25 14:42:05 linpubn218.gl.avaya.com systemd[1]: Starting SYSV: PostgreSQL database server.... Jul 25 14:42:06 linpubn218.gl.avaya.com runuser[29473]: pam_unix(runuser-l:session): session closed for user postgres Jul 25 14:42:08 linpubn218.gl.avaya.com postgresql[29464]: Starting postgresql service: [ OK ] Jul 25 14:42:08 linpubn218.gl.avaya.com systemd[1]: PID file /var/run/postmaster-8.4.pid not readable (yet?) after start. Jul 25 14:42:08 linpubn218.gl.avaya.com systemd[1]: Failed to start SYSV: PostgreSQL database server.. 作为前缀。 https://docs.arangodb.com/3.0/AQL/Fundamentals/BindParameters.html

通过此修改,您的代码应该有效:

@