Azurite
Azurite copied to clipboard
Querying a column of Guid type
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.
Step 2
Write a value of a Guid
type into the table
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
This is a bug. cc @blueww
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 appreciate the info but Azurite behavior is not related to how the query is formatted. Azurite should adhere to what the real service does.
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, could you assign this issue to the appropriate milestone to know when this fix goes out? Thank you.
@blueww & @XiaoningLiu approved changes are checked into main, can you help with flagging this for a milestone / release? Thanks.
@SeanFeldman , @edwin-huber , @XiaoningLiu We should have a planned release in the middle of Jan,2023.
The release is already out: https://github.com/Azure/Azurite/releases/tag/v3.21.0