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

Allow to define rename fields in $filterFields #65

Open
Lakshan-Madushanka opened this issue May 17, 2024 · 3 comments
Open

Allow to define rename fields in $filterFields #65

Lakshan-Madushanka opened this issue May 17, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@Lakshan-Madushanka
Copy link
Collaborator

Lakshan-Madushanka commented May 17, 2024

Currently, if we need to restrict fields and rename fields, we have to define both $availableFields and $renamedFields. It causes code duplication. We can avoid it with this feature.

@abbasudo
Copy link
Owner

Hey @Lakshan-Madushanka.

Please inform me of your solution before applying it so we can discuss it. And remember in Purity simplicity and extendibility is a priority.

@abbasudo
Copy link
Owner

abbasudo commented May 17, 2024

Currently, FilterFields values act as restrictions for filters

$filterFields = [
  'title' => ['$eq'],  // title will be limited to the eq operator
  'title' => '$eq',    // works only for one restricted operator
  'title:$eq',         // same as above
  'title',             // this won't be restricted to any operator
];

which itself is $restrictedFilters responsibility. However, we decided to merge it with $filterFields as it's more convenient and easier to implement and prevents duplication.
The restriction feature is more important and is used more often than renaming fields. If you have any implementation of defining renamed columns in $filterFields it should not conflict with the current functionalities of that variable.

@Lakshan-Madushanka
Copy link
Collaborator Author

@abbasudo What we do about this ?. How about something like following,

$filterFields = [ 'title as post_title' => ['$eq'], // title will be limited to the eq operator ];

We don't need to break any existing functionality. We can check for 'as' keyword existence, if so we can consider right side string as renamed column.

@abbasudo abbasudo closed this as completed Jun 8, 2024
@abbasudo abbasudo reopened this Jun 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants