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

Quote JSON path segments for query accessor. #1488

Closed

Conversation

kleinmann
Copy link
Contributor

@kleinmann kleinmann commented Nov 6, 2020

1. Why is this change necessary?

Usage of hyphenated fields in JSON fields in a DAL query currently results in a MySQL error "Invalid JSON path expression". Such fields must be quoted to be used in a query.

2. What does this change do, exactly?

It quotes all segments (separated by .) when building the field accessor for the MySQL query.

3. Describe each step to reproduce the issue or behaviour.

  • Create a custom field "my-hyphenated-field"
  • Use the custom field in a query:
$criteria->addFilter(new EqualsFilter('customFields.my-hyphenated-field', 'some value'));
  • See error during execution

4. Please link to the relevant issues (if any).

There's no issue yet, as far as I can tell.

5. Checklist

  • I have written tests and verified that they fail without my change
  • I have squashed any insignificant commits
  • I have created a changelog file with all necessary information about my changes
  • I have written or adjusted the documentation according to my changes
  • This change has comments for package types, values, functions, and non-obvious lines of code
  • I have read the contribution requirements and fulfil them.

@kleinmann
Copy link
Contributor Author

I am not sure if all relevant use cases of this accessor builder are present in my test. Suggestions would be much appreciated.

@kleinmann kleinmann force-pushed the fix/hyphenated-json-accessors branch from 59c3160 to 981cdcd Compare November 6, 2020 12:56
@kleinmann kleinmann force-pushed the fix/hyphenated-json-accessors branch from 981cdcd to b6e2788 Compare November 6, 2020 12:57
@kleinmann kleinmann marked this pull request as draft November 6, 2020 13:19
@kleinmann
Copy link
Contributor Author

Upon further testing and checking other cases from the failing tests, I think this can be solved more easily by adding quotes (like customFields."my-hyphenated-fields") directly in the filter arguments. I'm closing this PR :-)

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

Successfully merging this pull request may close these issues.

None yet

2 participants