azure-sdk-for-java icon indicating copy to clipboard operation
azure-sdk-for-java copied to clipboard

Table: Using OR with multiple EQ in TableQueryOptions.Query.Filter does not work

Open joostdenijs opened this issue 14 years ago • 1 comments

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:

http://azuresdkdev.table.core.windows.net/Tables('qaX813275Xb1') ... Even though the *a2 record exists (and can be obtained by this query:

GET /Tables?$filter=((TableName+ge+'qaX632023Xa2')+or+(TableName+le+'qaX632023Xb1')) HTTP/1.1

joostdenijs avatar Jul 16 '12 21:07 joostdenijs

We will discuss how to approach this next scrum.

joostdenijs avatar Jul 16 '12 23:07 joostdenijs