Skip to content

Conversation

@ArthurFreeb
Copy link

This pull request adds support for enum values in filter queries, allowing both quoted and unquoted enum symbols to be parsed and evaluated correctly. It introduces a new EnumSymbolLiteral AST node, updates the parser and evaluator logic to handle enums, and extends test coverage to verify enum filtering functionality. The changes also update the test data models to include a Status enum property for users.

Enum Support in Filter Parsing and Evaluation

  • Added a new AST node EnumSymbolLiteral to represent unquoted enum symbols in filter expressions, and updated the parser to recognize TokenType.IDENT as an enum value. [1] [2]
  • Enhanced the filter evaluator to detect enum and nullable enum types, and convert string, integer, and symbol literals to enum constants for expression evaluation. [1] [2] [3]
  • Improved error handling for invalid enum values and disallowed unquoted identifiers for non-enum types. [1] [2]

Parser and Primitive Type Updates

  • Updated the filter parser to allow unquoted identifiers (TokenType.IDENT) as valid right-hand side values in filter statements, enabling enum symbol parsing.
  • Modified primitive type detection logic to treat enums and nullable enums as primitive types for property mapping.

Test Data and Model Enhancements

Expanded Test Coverage

  • Added new unit tests for parsing and evaluating filters with enum values, including quoted and unquoted symbols, nested properties, and combined filter conditions. [1] [2] [3] [4]

These changes collectively enable robust support for enum filtering in queries, improve error detection, and ensure correctness through comprehensive testing.

@ArthurFreeb
Copy link
Author

I’ve allowed IDENT on the RHS and push the enum-only check to the evaluator. That keeps the grammar simple but still type-safe. Follow-ups I’m considering:
• Add tests for case-insensitive symbols and numeric RHS (status eq Active/active, status eq 0/1; nullable and non-nullable).
• Swap Enum.Parse for Enum.TryParse to avoid exceptions-as-control-flow.
• Decide whether undefined integer values should be rejected (Enum.IsDefined) or allowed as raw underlying values; I can tighten that if we want stricter semantics.

@Jamess-Lucass
Copy link
Member

Closing in favour of #105

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants