Skip to content

Fix formatter spacing for JSON path operators (->, ->>)#637

Merged
williamdes merged 2 commits intophpmyadmin:5.11.xfrom
Sea-n:master
Apr 1, 2026
Merged

Fix formatter spacing for JSON path operators (->, ->>)#637
williamdes merged 2 commits intophpmyadmin:5.11.xfrom
Sea-n:master

Conversation

@Sea-n
Copy link
Copy Markdown
Contributor

@Sea-n Sea-n commented Jan 21, 2026

Summary

  • Treat -> and ->> as SQL operators in the lexer.
  • Prevent formatter from inserting spaces around JSON path operators.
  • Add formatter test for JSON path access.

For example: SELECT details->'$."first_name"' FROM users;

Expected:

SELECT
    details->'$."first_name"'
FROM
    users;

Actual:

SELECT
    details - > '$."first_name"'
FROM
    users;

Caused SQL syntax error.

Tests

./vendor/bin/phpunit passed

I didn’t run ./vendor/bin/phpcbf as suggested in CONTRIBUTING.md because it currently changes about 60 files and produces roughly 150 lines of diff. If you’re okay with it, I’d love to handle that in a separate PR.

References

@Sea-n
Copy link
Copy Markdown
Contributor Author

Sea-n commented Jan 21, 2026

CC @MauricioFauth and @williamdes,
if you have a chance to review, I'd really appreciate it. Thanks!

Copy link
Copy Markdown
Member

@williamdes williamdes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks okay, thank you for adding a test
I will wait for another review from anyone else

@Sea-n
Copy link
Copy Markdown
Contributor Author

Sea-n commented Feb 1, 2026

Ping @MauricioFauth again,
please let me know if there are any advices

@MauricioFauth MauricioFauth self-assigned this Feb 10, 2026
@Sea-n
Copy link
Copy Markdown
Contributor Author

Sea-n commented Feb 20, 2026

Thanks again for the reviews!

I noticed two checks are still failing on this PR:

  • analyse-php (8.2)
  • Mutation tests with PHP 8.2 (Covered Code MSI 86% < required 88%)

Do these failures look related to my changes? If so, I’m happy to fix them right away.

Also, if rebasing onto the latest master would help, I can do that and push a follow-up quickly.

@MoonE
Copy link
Copy Markdown
Contributor

MoonE commented Feb 20, 2026

The Lint and analyze error is from a new Psalm version, not related to your changes.
The other error seems also unrelated.

@williamdes @MauricioFauth As a bug fix, should this go to 5.11.x?

@williamdes
Copy link
Copy Markdown
Member

The Lint and analyze error is from a new Psalm version, not related to your changes. The other error seems also unrelated.

@williamdes @MauricioFauth As a bug fix, should this go to 5.11.x?

Exactly, I did not merge this yet because of that.
The source branch can not be changed for that, I have manual work to do :/
Please do not touch anything

Sea-n and others added 2 commits April 1, 2026 17:24
- Treat `->` and `->>` as SQL operators in the lexer.
- Prevent formatter from inserting spaces around JSON path operators.
- Add formatter test for JSON path access.

For example:

```sql
SELECT
    details->'$."first_name"'
FROM
    users;
```

Signed-off-by: Sean Wei <me@sean.taipei>
Co-Authored-By: William Desportes <williamdes@wdes.fr>
…(->, ->>)

Pull-request: phpmyadmin#637
Signed-off-by: William Desportes <williamdes@wdes.fr>
@williamdes williamdes changed the base branch from master to 5.11.x April 1, 2026 15:27
@williamdes williamdes added this to the 5.11.2 milestone Apr 1, 2026
@williamdes williamdes merged commit caf6693 into phpmyadmin:5.11.x Apr 1, 2026
@williamdes
Copy link
Copy Markdown
Member

Thank you for your good work @Sea-n !
I added a test for ->>

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants