Table: Using OR with multiple EQ in TableQueryOptions.Query.Filter does not work
Moved from the private repository.
This looks like a bug in the Table service. I set up the TQO like this:
Random r = new Random();
int rint = r.nextInt(1000000);
testUniqueId = "qaX" + rint + "X";
TEST_TABLE_NAMES = new String[] { testUniqueId + "a1", testUniqueId + "a2", testUniqueId + "b1" };
for (String name : TEST_TABLE_NAMES) {
service.createTable(name);
}
options = new QueryTablesOptions();
query = new Query();
filter = Filter.or(
Filter.eq(Filter.litteral("TableName"), Filter.constant(TEST_TABLE_NAMES[1])),
Filter.eq(Filter.litteral("TableName"), Filter.constant(TEST_TABLE_NAMES[2])));
query.setFilter(filter);
options.setQuery(query);
QueryTablesResult ret = service.queryTables(options);
The URL generated looks right:
GET /Tables?$filter=((TableName+eq+'qaX401821Xa2')+or+(TableName+eq+'qaX401821Xb1')) HTTP/1.1
But no records are returned:
<feed ...> ... The problem seems to be that the EQ operators are ignored when there are other operators, which would explain the behavior above. That also seems to match the results of this query:
filter = Filter.or(Filter.eq(Filter.litteral("TableName"), Filter.constant(TEST_TABLE_NAMES[1])),
Filter.ge(Filter.litteral("TableName"), Filter.constant(TEST_TABLE_NAMES[2])));
Which makes the request:
GET /Tables?$filter=((TableName+eq+'qaX169947Xa2')+or+(TableName+ge+'qaX169947Xb1')) HTTP/1.1 Which only returns one record:
GET /Tables?$filter=((TableName+ge+'qaX632023Xa2')+or+(TableName+le+'qaX632023Xb1')) HTTP/1.1
We will discuss how to approach this next scrum.