Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#3153 closed defect (fixed)

handle null situation in JsonItemStore

Reported by: guest Owned by: Jared Jurkiewicz
Priority: high Milestone:
Component: Data Version: 0.9
Keywords: null jsonitemstore Cc:
Blocked By: Blocking:

Description

this is the test data used by the jsonItemStore:

{ identifier: 'abbr',
items: [
{ abbr:'ec', name:'Ecuador', capital:'Quito' },
{ abbr:'eg', name:'Egypt', capital:'Cairo' },
]}

it works well like this. but after I replace a value into null,for example:

{ identifier: 'abbr',
items: [
{ abbr:'ec', name:null, capital:'Quito' },
{ abbr:'eg', name:'Egypt', capital:'Cairo' },
]}

then it fails. I found the problem in dojo/data/JsonItemStore.js line281:

for(i = 0; i < arrayOfItems.length; ++i){
item = arrayOfItems[i];
for(var key in item){
var value = item[key];
if(!dojo.isArray(value)){
item[key] = [value];
}
attrNames[key]=key;
}
}

then I fixed it like this:

for(i = 0; i < arrayOfItems.length; ++i){
item = arrayOfItems[i];
for(var key in item){
var value = item[key];
if(value===null){
item[key]=[];
}else if(!dojo.isArray(value)){
item[key] = [value];
}
attrNames[key]=key;
}
}

now it can handle null situation

Attachments (1)

dojo.data_JsonItemStore_20070601.patch (7.4 KB) - added by Jared Jurkiewicz 12 years ago.
Minor patch to fix null attribute case.

Download all attachments as: .zip

Change History (8)

comment:1 Changed 12 years ago by Jared Jurkiewicz

Who opened this ticket? Have they signed a CLA? The noted code can't be used without a CLA in place.

comment:2 Changed 12 years ago by Jared Jurkiewicz

Component: GeneralData
Owner: changed from anonymous to skinner

comment:3 Changed 12 years ago by Jared Jurkiewicz

Owner: changed from skinner to Jared Jurkiewicz

comment:4 Changed 12 years ago by Jared Jurkiewicz

Status: newassigned

Working on a solution. Cannot use provided solution as submitter is unknown and CLA signature is also unknown. Plus, the solution isn't quite correct anyway.

Changed 12 years ago by Jared Jurkiewicz

Minor patch to fix null attribute case.

comment:5 Changed 12 years ago by Jared Jurkiewicz

Resolution: fixed
Status: assignedclosed

(In [8859]) Fix to handle null cases, as well as a performance fix + UT. fixes #3153

comment:6 Changed 12 years ago by Jared Jurkiewicz

Tested and verified on:

Windows:

IE 6.0 IE 7.0 Firefox 2.0.0.4 Firefox 1.5.0.11 Opera 9.2

OS-X:

WebKit?.

comment:7 Changed 12 years ago by Jared Jurkiewicz

Oh yeah, and also tested on SeaMonkey? 1.1.1

Note: See TracTickets for help on using tickets.