Skip to content

jsgi/rest-store.js: wrong content-range header value returned when store is empty #32

@websoftix

Description

@websoftix

I discovered it while working with a dgrid that uses the Pagination extension, a JsonRest store and on server side a mysql-store on an empty table.

The returned header is:
content-range: items 0--1/*

The observed effect is that dgrid displays on footer "Nan - Nan of NaN results".

The code that creates the header is on lines 117 - 118 of persvr/pintura/jsgi/rest-store.js:

var end = start + (responseValue.length || 0) - 1;
headers["content-range"] = "items " + start + '-' + end + '/' + (count || '*');

At first I though is because on line 117, when start is 0 and responseValue.length is also 0 the result in end will be -1. Even though end should be 0 it didn't caused the dgrid problem.

The problem is the * returned as the count value on 118 line because in dojo/store/JsonRest.js at line 220

return range && (range = range.match(/\/(.*)/)) && +range[1];

it is returned +(the-count-value) and +('*') is Nan.

I tested with Chrome 36 and Firefox 30 and the dgrid & dojo are last code from master.

My quick solution was to replace (count || '*') with (count || '0') in the line 117 but I'm not sure how correct that is.

Virgil

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions