-
Notifications
You must be signed in to change notification settings - Fork 123
Embedded SQL-Syntax only works for inline SQL #87
Comments
Atom uses textmate like grammar, if main principles of grammar is same then this one is impossible. That problem require a multiline matching of text, because it is not possible otherwise distinguish SQL string from regular string basing only on quote. Someone can fill bug/question about grammar to core devs? |
any updates? an issue where the string is incorrectly ended occurs with concatenated, embedded sql and it screws up the highlighting of the rest of the file |
@thisispiers You probably talking about other one, could you post test example which code broke highlight? That one is related only to case when you not get correct highlight if SQL is not single line. |
This is the same issue as #52, the switch to SQL gets broken with any break in the string. (Including, apparently, a newline.) |
@Arcanemagus I'm going to keep this one separate just in case. |
@Arcanemagus @50Wliu |
Yes it does: just use |
@50Wliu Yup in global it does. Problem so being and end is match only edges, and in that case there will be no different between SQL inside quotes and Str inside quotes. For detect this case there is need proper multiline regex with checks what is between begin and end. So for example is not possible to make expression(as simple example) like The other way to do it, is do quotes support in grammar and all cases inside them, it works if i'm correctly recall atom and textmate grammar. But itself way take too much time and efforts and still can give false positive in that case. The third way is to set begin and end to some uniq to SQL tokens, problem so SQL not have some special end token. |
We could match $foo = "-- SQL
SELECT *
FROM users
WHERE foo = 'bar'
"; |
@james-radford-854 That is a bit crazy way to invent syntax to cover highlight i'm would say. Since in that case everyone need to agree on that way and keep it, which i'm assume not happens. But yup will work in total |
I assume most people use PDO now and most people name their variables for SQL ̣ |
@PeteDevoy It basically not hard, you need file |
@zr9 Yes, thanks the tips. What you are saying sounds perfectly correct but unfortunately I do not think |
@PeteDevoy |
@PeteDevoy Yup, as @50Wliu said you can use source of package, it not require rebuilt whole atom source. If you not like |
In response to @james-radford-854 who said this:
I don't think there's anything wrong with controlling highlighing in comments. Perhaps a docblock tag would be better though. Maybe get in touch with the phpDocumentor creators and ask for some namespace in their keywords? https://phpdoc.org/contact Something like this for example:
|
I'm facing the same problem. Any update on this? |
If we used
results in: SELECT 'like so' FROM information_schema.tables WHERE true = true; |
I don't think a comment is enough. I think it should work with multiline regex. |
@mbomb007 grammar engine is limited, but it's still possible to use heredoc: $query = <<<SQL
SELECT `column`
FROM `table`
SQL; |
Whilst it's possible to use heredoc, it might conflict with some existing coding standards on projects it's an alternative that might not work for everyone (highlighted here: #385 (comment)) Is the grammar engine issue fixed by this PR? #303 . If my understanding is correct, it's currently using TextMate's grammar engine which does not support the level of multi-line matching we need for this to work, and the conversion to using tree-sitters (https://flight-manual.atom.io/hacking-atom/sections/creating-a-grammar/) is the way forward, should be more flexible, and will allow this issue to be fixed without weird workarounds + annotations? |
Please update this! It's really annoying having to write the whole query in one line just to get syntax highlighting. |
Used Atom Version: 1.0
Expected behaviour: Correct highlighting of SQL within PHP-Strings
Has this ever worked: No
Highlighting of SQL within strings is a very useful feature, but there's a little problem:
the language-php package only seems to highlight them if the beginning of the sql-statement lies on the same line as the opening of the string with quotation marks.
(Notice, that Lines 6-8 are all green)
The text was updated successfully, but these errors were encountered: