Azurite icon indicating copy to clipboard operation
Azurite copied to clipboard

Querying a column of Guid type

Open SeanFeldman opened this issue 2 years ago • 4 comments

Which service(blob, file, queue, table) does this issue concern?

Table

Which version of the Azurite was used?

3.17.1

Where do you get Azurite? (npm, DockerHub, NuGet, Visual Studio Code Extension)

npm

What's the Node.js version?

14.4.0

What problem was encountered?

When querying for a record with a column of Guid type w/o specifying the keyword guid in front of the value, Azurite returns the record where the real Storage Table would not.

Steps to reproduce the issue?

Step 1

Create a table with a custom column named InstructionId with Guid values in it. image

Step 2

Write a value of a Guid type into the table image

Step 3

Query for the item using the PartitionKey and the column value w/o using the guid keyword.

Guid instructionId = someGuidValue;
var pages = client.QueryAsync<TableEntity>($"PartitionKey eq '{userIdDeviceIdCompositeKey}' and InstructionId eq '{instructionId}'", maxPerPage: 1);

Assuming the table contains the record, Azurite will return it. The real storage account will not. To make it work with the real storage account, the following query must be used:

Guid instructionId = someGuidValue;
var pages = client.QueryAsync<TableEntity>($"PartitionKey eq '{userIdDeviceIdCompositeKey}' and InstructionId eq guid'{instructionId}'", maxPerPage: 1);

Note the InstructionId eq guid'{instructionId}'

Have you found a mitigation/solution?

No

SeanFeldman avatar May 18 '22 21:05 SeanFeldman

This is a bug. cc @blueww

SeanFeldman avatar May 20 '22 14:05 SeanFeldman

TableClient.CreateQueryFilter will convert a string based query filter to its escaped format. We have a sample to illustrate this. However, we might be able to have this happen automatically if a FormattableString is passed to the Query method.

BTW, here's the sample for TableClient.CreateQueryFilter https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/tables/Azure.Data.Tables/samples/Sample4QueryEntities.md#odata-formatted-string

christothes avatar May 20 '22 22:05 christothes

@christothes appreciate the info but Azurite behavior is not related to how the query is formatted. Azurite should adhere to what the real service does.

SeanFeldman avatar May 21 '22 00:05 SeanFeldman

Thanks for raising this. Agreed, we are aiming for service behaviors rather than documented behavior. I am working on several related issues to entity types and querying. I shall roll this up into that work.

edwin-huber avatar May 22 '22 14:05 edwin-huber

@edwin-huber, could you assign this issue to the appropriate milestone to know when this fix goes out? Thank you.

SeanFeldman avatar Dec 22 '22 17:12 SeanFeldman

@blueww & @XiaoningLiu approved changes are checked into main, can you help with flagging this for a milestone / release? Thanks.

edwin-huber avatar Dec 23 '22 08:12 edwin-huber

@SeanFeldman , @edwin-huber , @XiaoningLiu We should have a planned release in the middle of Jan,2023.

blueww avatar Dec 28 '22 13:12 blueww

The release is already out: https://github.com/Azure/Azurite/releases/tag/v3.21.0

blueww avatar Jan 09 '23 08:01 blueww