You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 15, 2022. It is now read-only.
Repository navigation
This repository was archived by the owner on Dec 15, 2022. It is now read-only.
SQL syntax coloring in string literals broken for versions greater than 0.51.9 #306
Checked that there is not already an Atom package that provides the described functionality: https://atom.io/packages
Description
I have been using Atom for Python coding for a while and I think the core language-python module works extremely well.
Updating Atom from version 1.36.1 to 1.37.0 or even the new 1.38.0 beta, something has changed though. Until version 0.59.1 of language-python, SQL code in string is correctly "syntax highlighted", while in subsequent versions (included in newer versions of Atom) is not. See the attached screenshots below.
Is there any way to restore the original behaviour? For long sql strings in code not having syntax highlighting is a major drawback. Thank you very much. Fabrizio
Steps to Reproduce
See screenshots attached
Expected behavior:
SQL syntax recognized (and properly colored) in string literals
SQL syntax not recognized in strings
Reproduces how often:
Always
Versions
Atom: 1.37.0 or greater
Language-Python: All versions after 0.59.1
Hello, I will attach the code below, but any sql string will do.
#!/usr/bin/env python3
from initclass import InitClass
import sys
import os
sys.path.append(os.path.abspath("../../"))
class Test(InitClass):
def __init__(self):
super().__init__()
def process(self):
# This is my comment
sql = "SELECT documents.* FROM documents"
documents = self.db.fetch_all(sql, [])
for document in documents:
print(document["name"])
t = Test()
t.process()
This is due to language-sql currently not having a Tree-sitter based implementation, meaning that language-python can't bring it in to syntax highlight the strings. You can check out atom/language-ruby#249 (comment) for a detailed explanation about this issue with regards to language-ruby, the core problem is the same though.
For now if you need that functionality you can switch to the old TextMate grammar by unchecking "Use Tree-sitter parsers" option:
Note however that the highlighting of your Python code (and other languages) will suffer from doing that, as TextMate grammars have many other issues with parsing that the Tree-sitter system allows us to solve easily.
Thanks @Arcanemagus, I wasn't aware of this issue, I still can't understand why for versions of atom under 1.37.0 the syntax highlight still works. My current atom setup is a downgraded 1.36.1 and even though "Use tree sitter parsers" is checked, it works like a charm and correctly highlights sql in strings, if I upgrade to 1.37.0 or newer it doesn't work anymore...
Activity
rsese commentedon Jun 5, 2019
Thanks for the report! Can you share the code itself so we can copy/paste to try it out?
fgiamma commentedon Jun 5, 2019
Hello, I will attach the code below, but any sql string will do.
Fabrizio
Arcanemagus commentedon Jun 5, 2019
This is due to
language-sqlcurrently not having a Tree-sitter based implementation, meaning thatlanguage-pythoncan't bring it in to syntax highlight the strings. You can check out atom/language-ruby#249 (comment) for a detailed explanation about this issue with regards tolanguage-ruby, the core problem is the same though.For now if you need that functionality you can switch to the old TextMate grammar by unchecking "Use Tree-sitter parsers" option:

Note however that the highlighting of your Python code (and other languages) will suffer from doing that, as TextMate grammars have many other issues with parsing that the Tree-sitter system allows us to solve easily.
fgiamma commentedon Jun 5, 2019
Thanks @Arcanemagus, I wasn't aware of this issue, I still can't understand why for versions of atom under 1.37.0 the syntax highlight still works. My current atom setup is a downgraded 1.36.1 and even though "Use tree sitter parsers" is checked, it works like a charm and correctly highlights sql in strings, if I upgrade to 1.37.0 or newer it doesn't work anymore...
contang0 commentedon Feb 23, 2020
For me downgrading to 1.36 doesn't help. Any chance this issue will be solved?