1
0
Fork 0

allow bind parameters in db._query()

This commit is contained in:
Jan Steemann 2013-06-21 17:13:51 +02:00
parent 373639a3b6
commit c74c80d5ff
4 changed files with 22 additions and 7 deletions

View File

@ -701,8 +701,13 @@ ArangoDatabase.prototype._createStatement = function (data) {
/// @brief factory method to create and execute a new statement /// @brief factory method to create and execute a new statement
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
ArangoDatabase.prototype._query = function (data) { ArangoDatabase.prototype._query = function (query, bindVars) {
return new ArangoStatement(this, { query: data }).execute(); var payload = {
query: query,
bindVars: bindVars || undefined
};
return new ArangoStatement(this, payload).execute();
}; };
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View File

@ -700,8 +700,13 @@ ArangoDatabase.prototype._createStatement = function (data) {
/// @brief factory method to create and execute a new statement /// @brief factory method to create and execute a new statement
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
ArangoDatabase.prototype._query = function (data) { ArangoDatabase.prototype._query = function (query, bindVars) {
return new ArangoStatement(this, { query: data }).execute(); var payload = {
query: query,
bindVars: bindVars || undefined
};
return new ArangoStatement(this, payload).execute();
}; };
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View File

@ -73,12 +73,13 @@ function DatabaseSuite () {
}, },
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief test name function /// @brief test _query function
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
testQuery : function () { testQuery : function () {
assertEqual([ 1 ], internal.db._query("return 1").toArray()); assertEqual([ 1 ], internal.db._query("return 1").toArray());
assertEqual([ [ 1, 2, 9, "foo" ] ], internal.db._query("return [ 1, 2, 9, \"foo\" ]").toArray()); assertEqual([ [ 1, 2, 9, "foo" ] ], internal.db._query("return [ 1, 2, 9, \"foo\" ]").toArray());
assertEqual([ [ 1, 454 ] ], internal.db._query("return [ @low, @high ]", { low : 1, high : 454 }).toArray());
} }
}; };

View File

@ -111,8 +111,12 @@ ArangoDatabase.prototype._createStatement = function (data) {
/// @brief factory method to create and execute a new statement /// @brief factory method to create and execute a new statement
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
ArangoDatabase.prototype._query = function (data) { ArangoDatabase.prototype._query = function (query, bindVars) {
return new ArangoStatement(this, { query: data }).execute(); var payload = {
query: query,
bindVars: bindVars || undefined
};
return new ArangoStatement(this, payload).execute();
}; };
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////