Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for custom field names in RQL struct tags #79

Merged
merged 1 commit into from
Mar 6, 2025

Conversation

whoAbhishekSah
Copy link
Member

Description

This PR enhances the field lookup functionality in the RQL parser to support custom field names via struct tags. Previously, the parser only matched against struct field names. With this change, users can now define custom field names using the name parameter in RQL struct tags, enabling more flexible API schemas.

Changes

  • Modified searchKeyInsideStruct function to check both struct field names and custom names defined in RQL tags
  • Added support for name= parameter in RQL struct tags
  • Maintained case-insensitive matching for both field names and custom names
  • Preserved backward compatibility with existing struct definitions

Example Usage

// Before
type Organization struct {
    BillingPlanName string    `rql:"type=string"`
}
// Could only be queried using "BillingPlanName"

// After
type Organization struct {
    BillingPlanName string    `rql:"name=plan_name,type=string"`
}
// Can be queried using both "BillingPlanName" and "plan_name"

Benefits

  • Allows for more intuitive API field names without changing struct field names
  • Enables better separation between internal struct representation and external API schema
  • Maintains backward compatibility with existing implementations
  • Simplifies API versioning and field renaming

Testing

  • Added unit tests for custom field name lookups
  • Verified backward compatibility with existing struct definitions
  • Tested case sensitivity handling

@rohilsurana rohilsurana merged commit 755f96f into main Mar 6, 2025
3 checks passed
@rohilsurana rohilsurana deleted the rql_field_name_tag branch March 6, 2025 11:31
whoAbhishekSah added a commit that referenced this pull request Mar 6, 2025
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