smartgwtpower5.0p.
We have a DatasourceField defined as
<field name="severity" type="text" title="severity" hidden="false" width="5%" initSortColumn="true" multiple="true" >
In the client code, we have
Criteria criteria = new Criteria();
String[] values = new String[4];
values[0] = "crit";
values[1] = "maj";
values[2] = "min";
values[3] = "warn";
criteria.setAttribute("severity", values);
When the user selects two values from the filter and runs the query, the where clause looks like this
WHERE ...
AND ((system_event_table.severity LIKE '%crit%' AND system_event_table.severity IS NOT NULL) OR (system_event_table.severity LIKE '%maj%' AND system_event_table.severity IS NOT NULL)) ...
However, when the user specifies start and end time as the filter criteria in another column, it seems like AdvancedCriteria is sent to the server and we see the where clause like this.
((system_event_table.severity = 'crit' AND system_event_table.severity IS NOT NULL) OR (system_event_table.severity LIKE 'crit, %' AND system_event_table.severity IS NOT NULL) OR (system_event_table.severity LIKE '%, crit, %' AND system_event_table.severity IS NOT NULL) OR (system_event_table.severity LIKE '%, crit' AND system_event_table.severity IS NOT NULL)) OR ((system_event_table.severity = 'maj' AND system_event_table.severity IS NOT NULL) OR (system_event_table.severity LIKE 'maj, %' AND system_event_table.severity IS NOT NULL) OR (system_event_table.severity LIKE '%, maj, %' AND system_event_table.severity IS NOT NULL)
Granted that the values are using the "OR" clause and since
the first value in the OR clause satisfies the query works fine. But this seems inefficient to have the where clause contain redundant clause and the wildcard pattern (i.e., LIKE '%, crit') when we know for sure that the column only holds enumerated values as listed in the client code.
Why is there two different behaviors (and two different queries) when time range is specified?
Looking at the data sent, the client logic seems to be sending the values in this manner.
criteria:[
{
value:"warn",
fieldName:"severity",
operator:"iEquals"
},
{
value:"warn, ",
fieldName:"severity",
operator:"iStartsWith"
},
{
value:", warn, ",
fieldName:"severity",
operator:"iContains"
},
{
value:", warn",
fieldName:"severity",
operator:"iEndsWith"
}
],
operator:"or
We have a DatasourceField defined as
<field name="severity" type="text" title="severity" hidden="false" width="5%" initSortColumn="true" multiple="true" >
In the client code, we have
Criteria criteria = new Criteria();
String[] values = new String[4];
values[0] = "crit";
values[1] = "maj";
values[2] = "min";
values[3] = "warn";
criteria.setAttribute("severity", values);
When the user selects two values from the filter and runs the query, the where clause looks like this
WHERE ...
AND ((system_event_table.severity LIKE '%crit%' AND system_event_table.severity IS NOT NULL) OR (system_event_table.severity LIKE '%maj%' AND system_event_table.severity IS NOT NULL)) ...
However, when the user specifies start and end time as the filter criteria in another column, it seems like AdvancedCriteria is sent to the server and we see the where clause like this.
((system_event_table.severity = 'crit' AND system_event_table.severity IS NOT NULL) OR (system_event_table.severity LIKE 'crit, %' AND system_event_table.severity IS NOT NULL) OR (system_event_table.severity LIKE '%, crit, %' AND system_event_table.severity IS NOT NULL) OR (system_event_table.severity LIKE '%, crit' AND system_event_table.severity IS NOT NULL)) OR ((system_event_table.severity = 'maj' AND system_event_table.severity IS NOT NULL) OR (system_event_table.severity LIKE 'maj, %' AND system_event_table.severity IS NOT NULL) OR (system_event_table.severity LIKE '%, maj, %' AND system_event_table.severity IS NOT NULL)
Granted that the values are using the "OR" clause and since
the first value in the OR clause satisfies the query works fine. But this seems inefficient to have the where clause contain redundant clause and the wildcard pattern (i.e., LIKE '%, crit') when we know for sure that the column only holds enumerated values as listed in the client code.
Why is there two different behaviors (and two different queries) when time range is specified?
Looking at the data sent, the client logic seems to be sending the values in this manner.
criteria:[
{
value:"warn",
fieldName:"severity",
operator:"iEquals"
},
{
value:"warn, ",
fieldName:"severity",
operator:"iStartsWith"
},
{
value:", warn, ",
fieldName:"severity",
operator:"iContains"
},
{
value:", warn",
fieldName:"severity",
operator:"iEndsWith"
}
],
operator:"or
Comment