Skip to content

Commit

Permalink
use supports() method to clarify which feature to be supported
Browse files Browse the repository at this point in the history
  • Loading branch information
stomita committed Sep 11, 2018
1 parent e4dd18a commit 986a2f1
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
12 changes: 11 additions & 1 deletion lib/api/tooling.js
Expand Up @@ -21,7 +21,6 @@ var Tooling = function(conn) {
var delegates = [
"query",
"queryMore",
"_ensureVersion",
"_toRecordResult",
"create",
"_createSingle",
Expand Down Expand Up @@ -91,6 +90,17 @@ Tooling.prototype._baseUrl = function() {
return this._conn._baseUrl() + "/tooling";
};

/**
* @private
*/
Tooling.prototype._supports = function(feature) {
// should return false in order not to use compsite collection
if (feature === 'sobject-collection') {
return false;
}
return this._conn._supports.apply(this._conn, arguments);
};

/**
* @private
*/
Expand Down
18 changes: 14 additions & 4 deletions lib/connection.js
Expand Up @@ -559,6 +559,16 @@ Connection.prototype._ensureVersion = function(majorVersion) {
return parseInt(versions[0], 10) >= majorVersion;
}

/** @private */
Connection.prototype._supports = function(feature) {
switch (feature) {
case 'sobject-collection':
return this._ensureVersion(42);
default:
return false;
}
}

/**
* Retrieve specified records
*
Expand All @@ -578,7 +588,7 @@ Connection.prototype.retrieve = function(type, ids, options, callback) {
options = options || {};
return (
_.isArray(ids) ?
(this._ensureVersion(42) ? // check the version whether SObject collection API is supported (42.0)
(this._supports('sobject-collection') ? // check whether SObject collection API is supported
this._retrieveMany(type, ids, options) :
this._retrieveParallel(type, ids, options)) :
this._retrieveSingle(type, ids, options)
Expand Down Expand Up @@ -722,7 +732,7 @@ Connection.prototype.create = function(type, records, options, callback) {
options = options || {};
return (
_.isArray(records) ?
(this._ensureVersion(42) ? // check the version whether SObject collection API is supported (42.0)
(this._supports('sobject-collection') ? // check whether SObject collection API is supported
this._createMany(type, records, options) :
this._createParallel(type, records, options)) :
this._createSingle(type, records, options)
Expand Down Expand Up @@ -835,7 +845,7 @@ Connection.prototype.update = function(type, records, options, callback) {
options = options || {};
return (
_.isArray(records) ?
(this._ensureVersion(42) ? // check the version whether SObject collection API is supported (42.0)
(this._supports('sobject-collection') ? // check whether SObject collection API is supported
this._updateMany(type, records, options) :
this._updateParallel(type, records, options)) :
this._updateSingle(type, records, options)
Expand Down Expand Up @@ -1046,7 +1056,7 @@ Connection.prototype.destroy = function(type, ids, options, callback) {
options = options || {};
return (
_.isArray(ids) ?
(this._ensureVersion(42) ? // check the version whether SObject collection API is supported (42.0)
(this._supports('sobject-collection') ? // check whether SObject collection API is supported
this._destroyMany(type, ids, options) :
this._destroyParallel(type, ids, options)) :
this._destroySingle(type, ids, options)
Expand Down

1 comment on commit 986a2f1

@AnanyaJha
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stomita Hi! I want to use the composite endpoint on my Tooling API create and update requests, and from the changes in this specific commit, it seems like that is no longer possible. Is there a reason the tooling api _supports method defaults to false

Please sign in to comment.