Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Bug using cacheAcrossOperationIds false [Fix included]

    Version: Smartclient V100p_2015-08-10_LGPL.

    Given:
    Code:
    isc.RestDataSource.create({
      ID:'Bug',
      cacheAllData:true,
      cacheAcrossOperationIds:false,
      cacheAllOperationId:'selectOptions'
    })
    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:
    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);
      }
    });
    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:
    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);
        }
    });

    #2
    Still no change on the latest build (2016-01-12LGPL). Is this being picked up?

    Comment


      #3
      This one was assigned for investigation but slipped through the priorties net a few times - it's now been fixed for all pertinent versions in builds dated January 16 and later.

      Comment

      Working...
      X