Version: Smartclient V100p_2015-08-10_LGPL.
Given:
The problem:
If you do a first fetch on the dataSource with selectOptions operationId the cache is nicely filled. But if you do a second fetch with an other operationId, the fetch fails.
The failing code is:
ISC_DataBinding.js@25780:
Why is it failing?
On the firstCacheAllDataRequest the transformRequest of the DataSource is overridden with a function which only fires if the request is an actual server request. This code does not take the option cacheAcrossOperationIds in consideration.
A possible fix:
Given:
Code:
isc.RestDataSource.create({ ID:'Bug', cacheAllData:true, cacheAcrossOperationIds:false, cacheAllOperationId:'selectOptions' })
If you do a first fetch on the dataSource with selectOptions operationId the cache is nicely filled. But if you do a second fetch with an other operationId, the fetch fails.
The failing code is:
ISC_DataBinding.js@25780:
Code:
this.addMethods({ transformRequest : function (dsRequest) { var isServerRequest = (dsRequest.cachingAllData || (dsRequest.operationType && dsRequest.operationType != "fetch")); if (!isServerRequest) return dsRequest; return this.transformServerRequest(dsRequest); }, transformResponse : function (dsResponse,dsRequest,data) { var isServerRequest = (dsRequest.cachingAllData || (dsRequest.operationType && dsRequest.operationType != "fetch")); if (!isServerRequest) { var cacheAllDataTime = this._autoCacheAllData_timestamp, sentTime = dsRequest._sentTime; if (!cacheAllDataTime || !sentTime || sentTime >= cacheAllDataTime) return dsResponse; } return this.transformServerResponse(dsResponse,dsRequest,data); } });
On the firstCacheAllDataRequest the transformRequest of the DataSource is overridden with a function which only fires if the request is an actual server request. This code does not take the option cacheAcrossOperationIds in consideration.
A possible fix:
Code:
this.addMethods({ isServerRequest: function(dsRequest){ return dsRequest.cachingAllData || (this.cacheAcrossOperationIds && (dsRequest.operationType && dsRequest.operationType != "fetch"))|| (this.cacheAcrossOperationIds===false && this.cacheAllOperationId!==(dsRequest.operationId||dsRequest.operation)) }, transformRequest : function (dsRequest) { if (!this.isServerRequest(dsRequest)) return dsRequest; return this.transformServerRequest(dsRequest); }, transformResponse : function (dsResponse,dsRequest,data) { if (!this.isServerRequest(dsRequest)) { var cacheAllDataTime = this._autoCacheAllData_timestamp, sentTime = dsRequest._sentTime; if (!cacheAllDataTime || !sentTime || sentTime >= cacheAllDataTime) return dsResponse; } return this.transformServerResponse(dsResponse,dsRequest,data); } });
Comment