I have a problem with some extra filtering that occurs on the server side even though I am using a custom datasource to do the original fetching/filtering.
The problem comes down to Date fields where sometimes the filter criteria has the Date value as a String ("2014-05-27") and other times the value is a Date object (Date(1401163200000), equates to "2014-05-27" or more specifically "2014-05-27 00:00:00" in Eastern TimeZone). I understand why it sometimes may come over that way ( and that is not a problem to us) as we handle both formats in our fetch methods and do the same lookup to the database and return the same record back. In the case of the Date filter value however, our record is removed from the response before the response is sent back to the client (only when the ds.xml contains an includeFrom field, see below).
I think the reason the record gets removed is because we send all our Date values to the client as String so as to not have any TimeZone problems since no time is included in the String value we return. I guess the "extra" filtering going on cannot match up the Date value with the String value.
I was surprised there was even this extra level of filtering going on at all on the server. Interestingly (you probably are aware of it) is that this extra server-side filtering only appears to take place when I have a ds.xml that contains an includeFrom field used as the displayField for a foreignKey field.
If I remove the displayField attribute as well as the the includeFrom field (in this case "calendarName") both scenarios work fine and the record is not removed.
Here are the 2 scenario details. The 2 response outputs are as follows, "Fetch Response:" is the response we send back at the very end of our fetch method and "JSResponse:" is the response being return by the servlet ala handleDSRequest method.
Working Scenario:
Advanced Criteria received on the Server:
Our fetch response which has the matching record:
The Servelet response:
Non-Working Scenario:
Advanced Criteria received on the Server:
Our fetch response which has the matching record:
The Servelet response:
The problem comes down to Date fields where sometimes the filter criteria has the Date value as a String ("2014-05-27") and other times the value is a Date object (Date(1401163200000), equates to "2014-05-27" or more specifically "2014-05-27 00:00:00" in Eastern TimeZone). I understand why it sometimes may come over that way ( and that is not a problem to us) as we handle both formats in our fetch methods and do the same lookup to the database and return the same record back. In the case of the Date filter value however, our record is removed from the response before the response is sent back to the client (only when the ds.xml contains an includeFrom field, see below).
I think the reason the record gets removed is because we send all our Date values to the client as String so as to not have any TimeZone problems since no time is included in the String value we return. I guess the "extra" filtering going on cannot match up the Date value with the String value.
I was surprised there was even this extra level of filtering going on at all on the server. Interestingly (you probably are aware of it) is that this extra server-side filtering only appears to take place when I have a ds.xml that contains an includeFrom field used as the displayField for a foreignKey field.
Code:
<field name="calendarName" includeFrom="calendar.name" /> <field name="calendar" foreignKey="calendar.sysId" displayField="calendarName" type="text" />
Here are the 2 scenario details. The 2 response outputs are as follows, "Fetch Response:" is the response we send back at the very end of our fetch method and "JSResponse:" is the response being return by the servlet ala handleDSRequest method.
Working Scenario:
Advanced Criteria received on the Server:
Code:
criteria:[ { fieldName:"tdate", operator:"equals", [b]value:"2014-05-27"[/b] } ]
Code:
Fetch Response: { endRow:1, affectedRows:0, totalRows:1, isDSResponse:true, invalidateCache:false, status:0, startRow:0, data:[ { sysUpdatedOn:new Date(1401198575377), name:"xxx", [b]tdate:"2014-05-27",[/b] sysId:"cdad3f8f92a64c29bed4ea715225fe88", } ] }
Code:
JSResponse: { endRow:1, affectedRows:0, totalRows:1, isDSResponse:true, invalidateCache:false, operationType:"fetch", status:0, startRow:0, data:[ { sysUpdatedOn:new Date(1401198575377), name:"xxx", [b]tdate:"2014-05-27",[/b] sysId:"cdad3f8f92a64c29bed4ea715225fe88", } ] }
Advanced Criteria received on the Server:
Code:
criteria:[ { fieldName:"tdate", operator:"equals", [b]value:new Date(1401163200000)[/b] } ]
Code:
Fetch Response: { endRow:1, affectedRows:0, totalRows:1, isDSResponse:true, invalidateCache:false, status:0, startRow:0, data:[ { sysUpdatedOn:new Date(1401198575377), name:"xxx", [b]tdate:"2014-05-27",[/b] sysId:"cdad3f8f92a64c29bed4ea715225fe88", } ] }
Code:
JSResponse: { endRow:0, affectedRows:0, totalRows:0, isDSResponse:true, invalidateCache:false, operationType:"fetch", status:0, startRow:0, data:[ ] }
Comment