sanity-io / GROQ

Specification for GROQ - The Query Language for JSON
https://groq.dev
MIT License
398 stars 15 forks source link

Feature Request: Typecasting in GROQ for String Comparison #120

Open bytegun opened 7 months ago

bytegun commented 7 months ago

Dear GROQ Development Team,

I'm writing to suggest a new feature for GROQ that would improve the handling of string comparisons, particularly when dealing with numeric-like strings.

Currently, I'm encountering difficulties when comparing strings that represent numbers. Since GROQ compares strings based on alphabetical order, it's challenging to accurately compare strings like "3500" and "500". This limitation makes it cumbersome to perform numeric comparisons within GROQ queries.

To address this issue, I propose the implementation of typecasting functionality in GROQ. With typecasting support, users would be able to explicitly convert string values to numeric types for comparison purposes. This would enable more accurate and intuitive comparisons, especially when dealing with numeric-like strings.

By introducing typecasting capabilities, GROQ would become more versatile and user-friendly, allowing developers to perform numeric comparisons with ease. This enhancement would greatly benefit users who frequently encounter scenarios where numeric-like strings need to be compared.

I believe that incorporating typecasting functionality into GROQ would enhance its capabilities and improve the overall developer experience. I hope you'll consider implementing this feature in future releases.

Thank you for considering my suggestion. I look forward to seeing further advancements in GROQ.

Sincerely