Salesforce-Inspector-reloaded icon indicating copy to clipboard operation
Salesforce-Inspector-reloaded copied to clipboard

feat[data-export]:add format query button to allow users to format SOQL queries

Open dyncan opened this issue 11 months ago • 6 comments

Describe your changes

Add a "Format Query" button to the [Data Export] section, allowing users to format their SOQL query for an enhanced view of the query's structure

Note: Currently the "Format Query" button does not support Comment and SOSL.

Issue ticket number and link

N/A

Checklist before requesting a review

  • [x] I have read and understand the Contributions section
  • [x] Target branch is releaseCandidate and not master
  • [x] I have performed a self-review of my code
  • [x] I ran the unit tests and my PR does not break any tests
  • [x] I documented the changes I've made on the CHANGES.md and followed actual conventions
  • [ ] I added a new section on how-to.md (optional)

dyncan avatar Mar 20 '24 02:03 dyncan

Hi @dyncan Thanks for this PR !

I think that the 'Format Query' button may be useful for users but I'm a little bit annoyed by adding a 287 KB file for this since minified react only weights 124 KB.

I would prefer a much lighter solution to handle the formating of SOQL

tprouvot avatar Mar 20 '24 16:03 tprouvot

Hi @tprouvot Thanks for the feedback.

I understand your concern, I'll look into alternatives and update accordingly.

dyncan avatar Mar 20 '24 22:03 dyncan

Hi @dyncan, Have you considered other options for formatting ?

tprouvot avatar Mar 29 '24 12:03 tprouvot

@tprouvot Currently, no better alternative has been found. I believe this library effectively resolves the issue of SOQL formatting. I also attempted to repackage and optimize the library’s source code using webpack, yet the size of the package still exceeds 200KB.

dyncan avatar Mar 29 '24 13:03 dyncan

Hi @dyncan, I'm not aware of the framework but I think our need is much more lighter than what soql-parser.js can do. Have you considered creating a function which parses the query for the basics needs of formatting ?

tprouvot avatar May 15 '24 09:05 tprouvot

Hi @tprouvot Formatting SOQL requires considering various scenarios, such as subqueries and nested subqueries, and complex where conditions, etc. which makes it somewhat complex. A few weeks ago, I implemented a simplified version that only supports basic SOQL queries (without subqueries ), and supporting more complex SOQL might be challenging.

dyncan avatar May 16 '24 05:05 dyncan

Hi @dyncan I'm closing this PR since the addition of a soql parser framework has been rejected for now. Please let me know if you want to implement a new custom beautifier. FYI the new version will support SOSL and GraphQL language in addition of SOQL

tprouvot avatar Jul 10 '24 09:07 tprouvot

Hi @tprouvot

Thank you for the update. I understand the decision and appreciate the information on the upcoming features.

I also look forward to contributing more meaningful PRs in the future.

dyncan avatar Jul 11 '24 01:07 dyncan