atom / language-sql

SQL package for Atom
Other
38 stars 50 forks source link

`WITH` keyword not tokenized? #21

Closed foresmac closed 7 years ago

foresmac commented 8 years ago

I looked through the grammar and could not find with or WITH which is used to begin a Common Table Expression (CTE).

May be related to atom/language-python#102.

thomasjo commented 8 years ago

Seems like you're correct. Feel free to submit a PR if you have time Aaaand it seems like you already did submit a PR :smiley:

thomasjo commented 8 years ago

Oh your PR was against the language-python repo; would you mind fixing it on this end as well, if you have time? :bow:

foresmac commented 8 years ago

Yeah, as soon as I figure out CoffeeScript I'll see what I can do!

The PR i submitted for atom/language-python#104 is so the python grammar will recognize embedded SQL statements that begin with the WITH keyword. However, it doesn't appear as though the SQL grammar recognizes the WITH keyword for proper highlighting to begin with.

foresmac commented 8 years ago

I think what I want is something that recognizes WITH as a keyword.other.cte.sql.

Then maybe I want something that does captures and uses a regex like: (with)\\s+(//w+)\\s+(as)

'1':
  'name': 'keyword.other.cte.sql'
'2':
  'name': 'entity.name.alias.sql' # maybe?
'3':
  'name': 'keyword.other.alias.sql'

Something like that, right? Sorry, I'm trying to parse how these grammars work.

nmat commented 8 years ago

WITH is also used in MS SQL queries:

SELECT * FROM table WITH(NOLOCK) WHERE something=something

etc.

So a highlight here would be good also.

Cxarli commented 8 years ago

Maybe this page could help you?

foresmac commented 8 years ago

@thomasjo Does my comment from Oct 9 make sense? I'm just not 100% certain how the grammar structure works. This is definitely outside my area of expertise but I'm willing to learn if there's some reference for how the grammar parser works.

50Wliu commented 7 years ago

Looks like WITH was added in #42. Closing.