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

JSON Query Filtering Support Added #50

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

AhmedMedDev
Copy link

I've integrated functionality to interpret JSON queries for filtering data within the package

@num8er
Copy link
Collaborator

num8er commented Apr 20, 2024

@AhmedMedDev please update master branch on Your side and push again.

@AhmedMedDev
Copy link
Author

@num8er done

@abbasudo
Copy link
Owner

Hey @AhmedMedDev. Thanks for your contribution. can you add some tests so I can see the implications of this feature?

@Lakshan-Madushanka
Copy link
Collaborator

@AhmedMedDev As packages is growing, It is crucial to submit new pull requests with relevant test cases.

I am quite skeptical about using the '->' symbol in query strings. Although '->' works with the 'where' clause, we need to manually change other query constraints. For example, if we need to find a JSON column (array) that contains a value, we have to use 'whereJsonContains', etc.

This would be a useful feature with proper implementation.

@AhmedMedDev
Copy link
Author

@Lakshan-Madushanka I appreciate your review, could you provide some guidance on how you think these features should be implemented more effectively?

@Lakshan-Madushanka
Copy link
Collaborator

@AhmedMedDev

  • Step 1:
    We need to find a way to internally identify JSON columns (which is not difficult with Laravel). Allowing the "->" symbol opens up a potential SQL injection vulnerability. This is the major reason why we have validated column names. Eloquent uses PDO behind the scenes, and PDO can only bind values, not column names. So, in your case, the following is possible:
    ?filter[name->;drop * from users;]=10.

  • Step 2:
    Implement JSON related filters here.

  • Step 3:
    Forward JSON columns to related JSON filters.

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.

None yet

4 participants