Skip to content

Commit

Permalink
[SQL] small refactor for create statements
Browse files Browse the repository at this point in the history
  • Loading branch information
keith-hall committed Sep 19, 2021
1 parent c4ec9c3 commit f5c2a72
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions SQL/SQL (basic).sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ version: 2

variables:
string_escape: (?:\\.)
dml_targets: (?:aggregate|conversion|database|domain|function|group|((?:fulltext|spatial|unique)\s+)?index|language|operator class|operator|procedure|rule|schema|sequence|table(?:space)?|trigger|type|user|view)
dml_targets: (?i:aggregate|conversion|database|domain|function|group|((?:fulltext|spatial|unique)\s+)?index|language|operator class|operator|procedure|rule|schema|sequence|table(?:space)?|trigger|type|user|view)

contexts:
prototype:
Expand Down Expand Up @@ -231,18 +231,9 @@ contexts:
- include: dml-statements

ddl-statements:
- match: |-
(?xi)
\b(create(?:\s+or\s+replace)?)\s+
({{dml_targets}})
\b\s*
(on)?\b
scope: meta.create.sql
captures:
1: keyword.other.create.sql
2: keyword.other.sql
3: keyword.other.sql
push: create-condition
- match: \b(?i:create(?:\s+or\s+replace)?)\b
scope: keyword.other.create.sql
push: ddl-create-target
- match: (?i:\s*\b(drop)\s+({{dml_targets}}))
scope: meta.drop.sql
captures:
Expand Down Expand Up @@ -271,6 +262,18 @@ contexts:
- match: (?i:\b(grant(\swith\sgrant\soption)?|revoke)\b)
scope: keyword.other.authorization.sql

ddl-create-target:
- meta_scope: meta.create.sql
- match: |-
(?xi)
({{dml_targets}})\b\s*
(on)?\b
captures:
1: keyword.other.sql
set: create-condition
- match: (?=\S)
pop: true

dml-statements:
- match: (?i:\bselect\b)
scope: keyword.other.DML.sql
Expand Down

0 comments on commit f5c2a72

Please sign in to comment.