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

[PHP] The SQL keywords WITH is not recognized a valid SQL. #3375

Closed
Luuk34 opened this issue May 8, 2022 · 2 comments · Fixed by #3331
Closed

[PHP] The SQL keywords WITH is not recognized a valid SQL. #3375

Luuk34 opened this issue May 8, 2022 · 2 comments · Fixed by #3331
Labels
T: bug A bug in an existing language feature

Comments

@Luuk34
Copy link

Luuk34 commented May 8, 2022

What happened?

The string is not formatted as SQL

<?php

$sql = "WITH RECURSIVE cte as (
            SELECT 1 as x
            UNION ALL
            SELECT x+1 FROM cte WHERE x<10)
        SELECT * FROM cte;";

When using a string that starts with SELECT then syntax coloring is working, as expected, but with the keyword WITH it stops working.

This bug-report was caused by this (stackoverflow)question: How to make PHP handeling my "WITH CTE as" SQL?

@Luuk34 Luuk34 added the T: bug A bug in an existing language feature label May 8, 2022
@jfcherng
Copy link
Collaborator

jfcherng commented May 8, 2022

and DROP btw. I am used to add DROP for my own.

@deathaxe
Copy link
Collaborator

deathaxe commented May 8, 2022

Maybe sync with Python.

deathaxe added a commit to deathaxe/sublime-packages that referenced this issue May 8, 2022
Fixes sublimehq#3375

This commit updates `sql_indicator` to detect more more kinds
of SQL queries.

- `IF ...` is borrowed from Python.sublime-syntax
- `DECLARE` is borrowed from T-SQL
deathaxe added a commit that referenced this issue May 21, 2022
[PHP] Refactor Syntax

Fixes #625
Fixes #643
Fixes #1168
Fixes #1665
Fixes #2459
Fixes #2625
Fixes #3214
Fixes #3375

Close #2789

This commit refactors PHP to...

1. solve known issues, such as huge syntax cache and compile times
2. improve maintainability and readability
3. apply some design patterns with regards to scope naming or syntax architecture

Major Changes
=============

- converts most contexts to named contexts
  - for readability reasons
  - to improve re-usability of contexts
  - to improve inheritance support

- organizes all rules into
  - declarations (classes, functions, ...)
  - statements (if, else, while, ...)
  - expressions (arithmetic, function-calls, ...)

- replaces (nearly) all `push ... with_prototype` constructs
  - to significantly reduce syntax cache size
  - gain more control over string interpolation scenarios `meta.string meta.interpolation`
  - significantly reduce risk of exceeding context sanity limit (see: #1665)

- applies scope changes to more closely follow recently discussed scope naming
- upgrades all parts to sublime-syntax version 2
- improves highlighting of incomplete statements and expressions
- improve support for syntax based folding 
  (as good as possible with regards to mixing HTML/CSS/JS with PHP)

Benchmarks
==========

Attribute                                         | ST4131   | this PR | Diff
--------------------------------------------------+----------+---------+--------------------
Syntax Cache Size                                 | 38.050kB | 7.481kB | -30.569kB (-80%)
Syntax Compile Time                               |     2,8s |    0,6s |    -2,2ms (-78,6%)
Syntax Test -- Performance [syntax_test_php.php]  |   11,2ms |   7,9ms |    -3.3ms (-29%)
Syntax Test -- Performance [PHPUnit/composer.php] |    557ms |   376ms |    -181ms (-32%)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T: bug A bug in an existing language feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants