Elfocrash / Cosmonaut

🌐 A supercharged Azure CosmosDB .NET SDK with ORM support
https://cosmonaut.readthedocs.io
MIT License
342 stars 44 forks source link

Raw SQL Identifier Match doesn't work with multiple spaces #105

Open tidusjar opened 4 years ago

tidusjar commented 4 years ago

When attempting to use the Raw SQL for the following query: select * from c order by c.id asc it does not match on the c identifier because there is a double space between the identifier and the operation (order). It seems that Github truncates the double space, but if you edit this post you can see there is a double space.

Now this is a bit of an edge case, but I found this as I was dynamically generating my order clauses and it happened to have an extra space. Ideally spacing between keywords shouldn't matter in the library since it doesn't matter to the underlying data provider.

There are the regular expressions I am referring to: https://github.com/Elfocrash/Cosmonaut/blob/develop/src/Cosmonaut/Extensions/CosmosSqlQueryExtensions.cs#L14

Elfocrash commented 4 years ago

Does the underlying sdk allow multiple spaces??

tidusjar commented 4 years ago

I'm not sure about the underlying sdk, but querying via Azure Portal seems to allow this.

This is not really a big issue, since I've now fixed my issue to not provide any extra spaces (for the better). But I was not expecting this behavior :smile:

EDIT: Also Azure Storage Explorer also allows this

Elfocrash commented 4 years ago

I would check how the underlying sdk reacts. It would be too tricky to write the regex for that if it’s not supported. I might pull the sql validation out of the CosmosDB sdk. I don’t consider this high priority.