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

[SQL] use inheritance to support different dialects #3046

Open
wants to merge 279 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
279 commits
Select commit Hold shift + click to select a range
09f5a6e
[SQL] support ALGORITHM=... in MySQL when creating views
keith-hall Oct 3, 2021
841225c
[SQL] initial Postgres support
keith-hall Oct 3, 2021
666c89e
[SQL] initial support for Apache Cassandra
keith-hall Oct 3, 2021
2227515
[SQL] reorganize syntax tests into subfolders
keith-hall Oct 4, 2021
daca95f
[SQL] fix pesky preserveIndent on comments preventing indentation tes…
keith-hall Oct 4, 2021
2536946
[SQL] improve Cassandra syntax test coverage slightly
keith-hall Oct 7, 2021
91b2f89
[SQL] misc TSQL improvements
keith-hall Oct 9, 2021
245c748
[SQL] fix TSQL function calls where the function name is in square br…
keith-hall Oct 9, 2021
696bc38
[SQL] fix TSQL "Optimize for" hints
keith-hall Oct 9, 2021
82f6060
[SQL] scope TSQL index hints more precisely
keith-hall Oct 9, 2021
a527926
[SQL] fix T-SQL PIVOT/UNPIVOT without table alias
keith-hall Oct 10, 2021
ea42460
[SQL] tighten context for clarity
keith-hall Oct 10, 2021
e92279b
[SQL] scope partition keys in CQL, joins don't exist
keith-hall Oct 12, 2021
9067ab5
[SQL] scope constraint names correctly in table definitions
keith-hall Oct 12, 2021
e9ffa2d
[SQL] scope references correctly, scope filegroups in TSQL
keith-hall Oct 12, 2021
c283637
[SQL] fix tmPreferences
jrappen Oct 12, 2021
700f8f8
[SQL] split tests into separate ones for:
jrappen Oct 12, 2021
7224d18
[SQL] minor syntax file readability improvements
jrappen Oct 12, 2021
ff347d1
[SQL] rename syntax test file
jrappen Oct 12, 2021
076427b
[SQL] clean up symbols tests
jrappen Oct 13, 2021
0d66768
Merge pull request #10 from jrappen/sql
keith-hall Oct 13, 2021
6e3c84c
[SQL] Support opening paren directly after TOP with no whitespace bet…
keith-hall Oct 15, 2021
adaaf66
[SQL] improvements to Cassandra syntax
keith-hall Oct 18, 2021
488ee10
Apply suggestions from code review
keith-hall Oct 23, 2021
73c8870
[SQL] improvements from code review
keith-hall Oct 23, 2021
caa1cb7
Apply suggestions from code review
keith-hall Oct 23, 2021
6c4ffea
[SQL] tweak to Cassandra "select json" scope
keith-hall Oct 23, 2021
0c3df74
[SQL] add meta_include_prototype false to name contexts
keith-hall Oct 23, 2021
843f708
[SQL] make ignore case/word boundary order consistent
keith-hall Oct 23, 2021
16e9e12
[SQL] make keyword.other.DML scope lowercase to match all other scopes
keith-hall Oct 23, 2021
545ddcb
[SQL] Update Python MySQL syntax tests
keith-hall Oct 25, 2021
edb2e68
Merge branch 'master' into sql
keith-hall Nov 3, 2021
a305dc7
[SQL] Support MySQL temporary table creation
keith-hall Nov 12, 2021
8940b18
[SQL] Improve Postgres syntax support
keith-hall Nov 12, 2021
ae58314
[SQL] move ddl-create-target-expect-as to base syntax
keith-hall Nov 13, 2021
a4754f4
[SQL] scope columns in a table creation context specifically
keith-hall Nov 13, 2021
bdd4b7e
[SQL] (WIP) refactor to support scoping of types only in a type context
keith-hall Nov 13, 2021
e246202
[SQL] Correctly scope types for variable declarations in Postgres syntax
keith-hall Nov 13, 2021
ee8a3f5
[SQL] fix Cassandra and TSQL syntax tests after context-specific type…
keith-hall Nov 14, 2021
22a8677
[SQL] support included columns in TSQL indexes
keith-hall Nov 30, 2021
d3357e8
Merge pull request #11 from forkeith/more_sql
keith-hall Nov 30, 2021
ac08fc6
Merge remote-tracking branch 'sublimehq/master' into sql
keith-hall Nov 30, 2021
5350f07
[SQL] fix Ruby syntax tests
keith-hall Nov 30, 2021
9f56575
[SQL] resolve Postgres TODO comments from syntax test file
keith-hall Dec 7, 2021
3c4eeaf
[SQL] only scope a leading asterisk in documentation block comments
keith-hall Dec 17, 2021
fdcbe5e
[SQL] Enable variable interpolations
deathaxe Dec 18, 2021
478d1ac
Merge pull request #12 from deathaxe/sql
keith-hall Dec 18, 2021
7e72cf5
[SQL] improve block comment handling
keith-hall Feb 11, 2022
3470a3d
Merge remote-tracking branch 'sublimehq/master' into sql
keith-hall Feb 12, 2022
454877f
[SQL] fixes after merge from master branch
keith-hall Feb 12, 2022
67f8cb5
Apply suggestions from code review
keith-hall Feb 13, 2022
bc9e021
[SQL] fixes
keith-hall Feb 14, 2022
0dfb869
Merge branch 'master' into sql
deathaxe Mar 6, 2022
2ef35ee
[SQL] Update Embedded PHP SQL syntaxes
deathaxe Mar 6, 2022
6f903b5
Merge pull request #13 from deathaxe/sql
keith-hall Mar 6, 2022
5e130b9
[SQL] improve TSQL foreign key and temporal table support
keith-hall Mar 6, 2022
ee39f29
[SQL] Rename PostgresSQL to PostgreSQL
azizk Apr 12, 2022
a49f534
Merge pull request #14 from azizk/aziz/postgres
keith-hall Apr 14, 2022
c6d4ccc
[SQL] Added Postgres `.psql` file extension and renamed the test.
azizk Apr 20, 2022
c7ada36
[SQL] Change `postgresql` scope suffix to `psql`.
azizk Apr 20, 2022
4c207bc
Merge pull request #15 from azizk/psql-contributions
keith-hall Apr 21, 2022
29cb4a9
Merge remote-tracking branch 'sublimehq/master' into sql
keith-hall Apr 21, 2022
ad5e59f
[SQL] fix syntax tests
keith-hall Apr 21, 2022
aac3833
Merge remote-tracking branch 'sublimehq/master' into sql
keith-hall May 16, 2022
acfbeeb
[SQL] rename entity.name.function to entity.name.struct for table def…
keith-hall May 17, 2022
5868db6
Merge branch 'master' into sql
deathaxe May 21, 2022
511206a
[PHP] Fix interpolation
deathaxe May 21, 2022
548752d
Merge pull request #16 from deathaxe/sql
keith-hall May 21, 2022
f586ddc
Remove unnecessary directives
deathaxe Jun 7, 2022
7d7fe03
Reorg string-escapes
deathaxe Jun 7, 2022
29320a9
Add meta.string
deathaxe Jun 7, 2022
ef8716b
Reorganize number/consant/string literals
deathaxe Jun 7, 2022
b4e0456
Add scope for decimal point
deathaxe Jun 7, 2022
301bddf
TSQL: Scope hexadecimal base
deathaxe Jun 7, 2022
e8eee03
Reorganize inside-... contexts
deathaxe Jun 7, 2022
cf0bed6
[SQL] A few improvements
keith-hall Jun 7, 2022
4ca8ec5
Rename inside-single-quoted-string context
deathaxe Jun 10, 2022
9f10f81
Reorganize groups contexts
deathaxe Jun 10, 2022
27a6a5f
Reorganize function-call contexts
deathaxe Jun 10, 2022
db1faa0
Reorganize case expression contexts
deathaxe Jun 10, 2022
e2de580
Reorganize alias expression contexts
deathaxe Jun 10, 2022
3f82531
Reorganize collate expression contexts
deathaxe Jun 10, 2022
998f7a1
Tweak case insenstive alterantion
deathaxe Jun 10, 2022
b941956
Reuse else-pop and immediately-pop
deathaxe Jun 10, 2022
a3b4290
Tweak declarations
deathaxe Jun 10, 2022
86ac1c4
Refactor wildcard identifiers
deathaxe Jun 12, 2022
6d68d53
Use more efficient lookahead to skip whitespace
deathaxe Jun 12, 2022
6f32bbe
Refactor `cast` as builtin function-call
deathaxe Jun 12, 2022
e0c8b41
Reorganize TSQL table creation
deathaxe Jun 13, 2022
02123eb
Remove unnecessary word boundary checks
deathaxe Jun 13, 2022
c25d4dd
Reorg prototypes
deathaxe Jun 15, 2022
f6965b9
Reorg comments
deathaxe Jun 15, 2022
ad6c269
Reorg identifiers
deathaxe Jun 15, 2022
c6e3dcd
Refactor/fix identifier boundaries
deathaxe Jun 15, 2022
db7dad4
Add support for interpolated identifiers
deathaxe Jun 16, 2022
472603b
Reorganize reserved word bailout
deathaxe Jun 17, 2022
e73d683
Refactor table-name-or-subquery
deathaxe Jun 17, 2022
a6087e1
More expressive identifier patterns
deathaxe Jun 19, 2022
7f11859
Simplify cte column list contexts
deathaxe Jun 20, 2022
b0a5c05
Reorganize operators
deathaxe Jun 23, 2022
f6f10ef
Reorganize literals (constants, numbers, strings, variables)
deathaxe Jun 23, 2022
23708c7
Reorganize LIKE expressions
deathaxe Jun 23, 2022
bc14941
Reorganize types
deathaxe Jun 26, 2022
1471890
Add expressions separator
deathaxe Jun 26, 2022
bc056c9
Reorganize statement contexts
deathaxe Jun 26, 2022
b23344c
Less restrictive whitespace
deathaxe Jun 26, 2022
4c84c20
Fix cursor expressions
deathaxe Jun 26, 2022
ed8cb47
Refactor column modifiers
deathaxe Jul 1, 2022
5597b02
Add meta scopes to arrays, dicts/sets
deathaxe Jul 1, 2022
9c56e2e
Fix Cassandra collection types
deathaxe Jul 2, 2022
9d539e1
Update main keys order
deathaxe Jul 2, 2022
ae27fa1
Tweak casing
deathaxe Jul 4, 2022
49d6ad8
Refactor TABLESAMPLE contexts
deathaxe Jul 5, 2022
26a1ea5
Lowercase keyword scopes
deathaxe Jul 5, 2022
0607a8b
Remove duplicate pattern
deathaxe Jul 5, 2022
e4e0bc2
Add reusable comma and semicolon context
deathaxe Jul 5, 2022
45a616d
Reorganize T-SQL "with" expressions
deathaxe Jul 5, 2022
0711ff9
Reorganize T-SQL table-names-or-subquery
deathaxe Jul 5, 2022
7ee6154
Tweak T-SQL cursor declaration
deathaxe Jul 5, 2022
543c1eb
Refactor variables
deathaxe Jul 5, 2022
e6ee23f
Convert all case-insensitive patterns to lower-case
deathaxe Jul 5, 2022
6d913dc
Fix T-SQL "alter" statement
deathaxe Jul 5, 2022
9e4dbf3
Rename expressions-or-column-names to plural
deathaxe Jul 6, 2022
0ed3589
Fix last computed column in group
deathaxe Jul 6, 2022
a58db1d
Fix on/off boolean scopes and create reusable contexts
deathaxe Jul 6, 2022
286372c
Merge pull request #18 from deathaxe/sql
keith-hall Jul 7, 2022
3e58cb8
[SQL] Small context name typo fix
keith-hall Jul 7, 2022
0799802
Refactor column declaration lists
deathaxe Jul 8, 2022
10e4c1e
Avoid including `main`.
deathaxe Jul 8, 2022
4cc98a3
Merge pull request #19 from deathaxe/sql
keith-hall Jul 9, 2022
f8c096d
T-SQL: Add missing keywords
deathaxe Jul 9, 2022
7006e54
Sort identifier contexts alphabetically
deathaxe Jul 10, 2022
3ea6eb0
Cassandra: Reorganize partition key contexts
deathaxe Jul 10, 2022
5369bbb
Refactor ddl statements
deathaxe Jul 10, 2022
969fcd1
P-SQL: Improve CREATE INDEX statements
deathaxe Jul 10, 2022
4278b99
Cassandra rename type scope
deathaxe Jul 11, 2022
257cba7
Remove `ddl-` from context names
deathaxe Jul 16, 2022
9476e36
Rename `target-as` to `target-options`
deathaxe Jul 16, 2022
ad140af
Rename statement meta scopes
deathaxe Jul 16, 2022
bb5d3e9
T-SQL: Remove duplicate index-name contexts
deathaxe Jul 17, 2022
7f7daf6
MySQL: Add CREATE/ALTER/DROP USER statements
deathaxe Jul 12, 2022
a03ac2f
MySQL: Add GRANT statements
deathaxe Jul 14, 2022
d2dd962
MySQL: Fix account names
deathaxe Jul 15, 2022
cb17a71
MySQL: Add RENAME USER statements
deathaxe Jul 15, 2022
da874e9
MySQL: Add REVOKE statements
deathaxe Jul 15, 2022
df5be4c
MySQL: Add SET PASSWORD statements
deathaxe Jul 16, 2022
dae0ec0
MySQL: Add CREATE ROLE statements
deathaxe Jul 16, 2022
d7ab07f
MySQL: Add DROP ROLE statements
deathaxe Jul 16, 2022
1d21f06
MySQL: Add SET ROLE statements
deathaxe Jul 16, 2022
d324986
MySQL: Add SHOW ROLE statements
deathaxe Jul 16, 2022
5707b4f
MySQL: Add SHOW CREATE USER statements
deathaxe Jul 16, 2022
6f9e8cb
MySQL: Refactor algorithm assignments
deathaxe Jul 17, 2022
90096a5
MySQL: Reorganize test categories
deathaxe Jul 16, 2022
d9e2f22
MySQL: Reorganize column declaration expressions
deathaxe Jul 17, 2022
5e3e28a
MySQL: Add CREATE DATABASE/SCHEMA statements
deathaxe Jul 17, 2022
59641a2
MySQL: Add ALTER DATABASE/SCHEMA statements
deathaxe Jul 17, 2022
dd8a9bd
MySQL: Add DROP DATABASE/SCHEMA statements
deathaxe Jul 17, 2022
4268bb6
MySQL: Add CREATE EVENT statements
deathaxe Jul 17, 2022
866e570
MySQL: Add ALTER EVENT statements
deathaxe Jul 17, 2022
3b02297
MySQL: Add DROP EVENT statements
deathaxe Jul 17, 2022
3dce643
MySQL: Add SHOW CREATE EVENT statements
deathaxe Jul 17, 2022
e9341b0
MySQL: Refactor SHOW statements
deathaxe Jul 17, 2022
a13c93d
MySQL: Add CREATE FUNCTION/PROCEDURE statements
deathaxe Jul 17, 2022
ae8b1ce
MySQL: Reorganize DEFINER expressions
deathaxe Jul 17, 2022
ff5f685
MySQL: Fix typo
deathaxe Jul 18, 2022
b6960a6
NySQL: Reorganize comments
deathaxe Jul 21, 2022
9e4e60c
MySQL: Reuse `interval` in user creations
deathaxe Jul 18, 2022
59c0d87
MySQL: Add some BNF comments
deathaxe Jul 18, 2022
3ac3b2d
MySQL: Add CREATE PROCEDURE tests
deathaxe Jul 18, 2022
253037d
MySQL: Add CREATE FUNCTION UDF statements
deathaxe Jul 18, 2022
412bf15
SQL: Common scheme of DDL statement arguments
deathaxe Aug 4, 2022
0fdce03
MySQL: Add CREATE/DROP INDEX statements
deathaxe Aug 6, 2022
5fe0636
MySQL: Improve CREATE TABLE statements
deathaxe Aug 6, 2022
f7cd539
Merge branch 'master' into mysql
keith-hall Jul 12, 2023
dab0197
[SQL] PHP fixes
keith-hall Jul 30, 2023
f88d5a8
Merge branch 'master' into mysql
keith-hall Jul 31, 2023
9b67bd8
[SQL] more improvements
keith-hall May 2, 2023
ebca675
[SQL] support GRANT UPDATE permission TO user
keith-hall Jul 31, 2023
b26f93d
[SQL] support clustered index creation
keith-hall Jul 31, 2023
33c5a06
[SQL] support GRANT SELECT permission ON schema TO user
keith-hall Jul 31, 2023
1fef6f9
[SQL] fix Golang SQL embedding
keith-hall Jul 31, 2023
990b166
[SQL] support GRANT INSERT permissions
keith-hall Jul 31, 2023
fb8ef15
Merge remote-tracking branch 'sublimehq/master' into sql
keith-hall Aug 4, 2023
733265f
[SQL] manually make the wildcard scope adjustments after merge from m…
keith-hall Aug 4, 2023
d67c718
[SQL] more manual wildcard scope adjustments
keith-hall Aug 4, 2023
a99b7ea
fix after merge from master reintroduced syntax test file which was m…
keith-hall Aug 4, 2023
edb2cc7
[SQL] improve postgresql syntax slightly
keith-hall Aug 12, 2023
dc1185a
[SQL] Move user identifier to SQL (Basic)
deathaxe May 16, 2023
128b16f
[SQL] Add variable for builtin scalar functions
deathaxe Aug 2, 2023
fce8721
[SQL] Reorganize grant/revoke statements & expressions
deathaxe Aug 2, 2023
a1337d7
[SQL] merge MySQL and T-SQL user privileges
deathaxe Aug 2, 2023
c92f79a
[SQL] fix ALL PRIVILEGES
deathaxe Aug 17, 2023
5628ec1
[SQL] Add missing class types
deathaxe Aug 17, 2023
436ba5a
[SQL] Add generic class type
deathaxe Aug 17, 2023
aeb3ce6
[SQL] Restrict user@host to MySQL
deathaxe Aug 17, 2023
42b187c
[SQL] additional fixes for TSQL
keith-hall Aug 18, 2023
649b960
[SQL] use tabs for indentation in tmPreferences files
keith-hall Aug 18, 2023
02161ef
[SQL] update URL in Cassandra syntax comment
keith-hall Aug 18, 2023
7e834cd
[SQL] PostgreSQL improvements
keith-hall Aug 21, 2023
59d96d8
[SQL] improve scoping of escapes inside bytea strings in PostgreSQL
keith-hall Aug 21, 2023
880068a
[SQL] support CREATE SEQUENCE in TSQL
keith-hall Aug 21, 2023
8073d9d
[SQL] correctly scope TSQL table variable columns
keith-hall Aug 21, 2023
f7fffad
[SQL] correctly scope TSQL transaction isolation levels
keith-hall Aug 21, 2023
cf6f640
[SQL] improve scoping of function parameters in TSQL
keith-hall Aug 23, 2023
a107580
[SQL] move READONLY to after-type context in TSQL syntax
keith-hall Aug 22, 2023
bc5af53
[SQL] add support for CREATE TYPE ... AS TABLE
keith-hall Aug 22, 2023
272041d
[SQL] support grant view server state in TSQL
keith-hall Aug 22, 2023
5b1f29d
[SQL] support GRANT EXECUTE
keith-hall Aug 22, 2023
5b2d73d
[SQL] better support for MERGE statements in TSQL
keith-hall Aug 23, 2023
8d22bf3
[SQL] add support for DEFAULT when doing inserts
keith-hall Aug 23, 2023
42ea97d
[SQL] support cross join
keith-hall Aug 29, 2023
b574398
[SQL] support deadlock_priority in TSQL
keith-hall Aug 29, 2023
cc2a871
[SQL] add support for TSQL `ALTER TABLE ... WITH CHECK` and temp tables
keith-hall Oct 25, 2023
1f5edee
[Go] add support for TSQL in language injections
keith-hall Oct 25, 2023
d55ba7c
[SQL] fix some case-insensitive flags
deathaxe Sep 9, 2023
071f96b
[SQL] Improve JOIN syntax
deathaxe Sep 9, 2023
1cf5566
[SQL] Fix maybe-on-table-name
deathaxe Sep 16, 2023
9176138
[SQL] Rename column-reference-list
deathaxe Sep 17, 2023
2c29093
[SQL] Drop redundant pattern
deathaxe Sep 23, 2023
ec6fdc6
[SQL] Move stray brackets into separate contexts
deathaxe Sep 23, 2023
ae2f0da
[SQL] Globally match reserved/built-in types
deathaxe Sep 30, 2023
f04117c
[SQL] Add globally reserved words
deathaxe Sep 30, 2023
245a439
[SQL] Simplify literal constants
deathaxe Sep 25, 2023
3205950
[SQL] Add variables
deathaxe Sep 30, 2023
dcc2a93
[SQL] Add string literal tests
deathaxe Sep 30, 2023
d79bcbe
[SQL] Add ALTER TABLE support for MySQL
deathaxe Sep 29, 2023
ced5671
[SQL] Re-add accidentally dropped syntax tests
deathaxe Oct 26, 2023
d837ea3
[SQL] Add some drop user tests
deathaxe Oct 26, 2023
9ab469d
[SQL] fix failing syntax test
keith-hall Oct 31, 2023
6dcaafe
[SQL] reintroduce distinction between table aliases and column aliases
keith-hall Oct 31, 2023
24583c3
[SQL] remove unnecessary include
keith-hall Oct 31, 2023
6a0de68
[SQL] small tweak to keep using base syntax as much as possible
keith-hall Oct 31, 2023
c49b7f8
[SQL] Fix PHP interpolation
deathaxe Nov 1, 2023
5d51874
Merge remote-tracking branch 'sublimehq/master' into sql
keith-hall Nov 2, 2023
a4bad73
[SQL] fix source.sql scope not being applied to DELETE statements in …
keith-hall Nov 13, 2023
734d51d
[SQL] fix foreign key column name references and unique constraints
keith-hall Nov 13, 2023
b639a41
[SQL] fix ALTER TABLE ... ADD sequence TYPE not being scoped correctly
keith-hall Nov 26, 2023
7477d3f
[SQL] fix DROP USER scoping of user names beginning with IF
keith-hall Nov 13, 2023
88751b5
[SQL] fix TSQL MERGE WHEN expressions
keith-hall Nov 14, 2023
d7c0650
[SQL] apparently the maybe-merge-insert context was never really needed
keith-hall Nov 14, 2023
f05d8fa
Merge branch 'master' into sql
keith-hall Jun 3, 2024
a2205e9
[SQL] add some TSQL WITH XMLNAMESPACES examples/tests
keith-hall Jun 3, 2024
827b729
Merge remote-tracking branch 'sublimehq/master' into sql
Jul 14, 2024
1c49ea3
[SQL] add boolean sub-scopes
Jul 14, 2024
e4923a6
Merge remote-tracking branch 'sublimehq/master' into sql
Sep 5, 2024
7abb7f4
[MySQL] scope built in variables, parameters and duplicate key behavior
Sep 29, 2024
ed66b5e
Merge branch 'master' into sql
Sep 29, 2024
b571b85
[MySQL] support LIKE expressions with # as an escape character
Sep 29, 2024
fd38f1e
[SQL] more improvements to MySQL syntax
Oct 17, 2024
2efa4a8
Merge remote-tracking branch 'sublimehq/master' into sql
Nov 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
140 changes: 140 additions & 0 deletions SQL/MySQL.sublime-syntax
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
%YAML 1.2
---
name: MySQL
scope: source.sql.mysql
version: 2
extends: Packages/SQL/SQL (basic).sublime-syntax

contexts:
main:
- meta_append: true
- include: regexps

comments:
- meta_append: true
- match: '#'
scope: punctuation.definition.comment.sql
push: inside-number-sign-comment

double-dash-comments:
- meta_include_prototype: false
- match: '--(?=\s)'
scope: punctuation.definition.comment.sql
push: inside-double-dash-comment

strings:
- meta_append: true
- match: "`"
scope: punctuation.definition.string.begin.sql
push:
- meta_include_prototype: false
- meta_scope: string.quoted.other.backtick.sql
- match: "`"
scope: punctuation.definition.string.end.sql
pop: true
- include: string-escape
- match: '"'
scope: punctuation.definition.string.begin.sql
push:
keith-hall marked this conversation as resolved.
Show resolved Hide resolved
- meta_include_prototype: false
- meta_scope: string.quoted.double.sql
- match: '""'
scope: constant.character.escape.sql
- match: '"'
scope: punctuation.definition.string.end.sql
pop: true
- include: string-interpolation
- include: begin-interpolation

begin-interpolation:
- match: '%\{'
scope: punctuation.definition.string.begin.sql
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct me if I am wrong but does string interpolation in SQL behave the same as normal string interpolations like Python, C# etc. ? If so, then shouldn't this be punctuation.definition.interpolation.begin.sql (If so perhaps have a separate scope for leading % as punctuation.definition.interpolation.sql ?)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest, I have no idea how interpolations work in MySql. My plan was just to leave it as it is (i.e. before this PR) in the hope that someone with more experience can improve upon it later.

push:
keith-hall marked this conversation as resolved.
Show resolved Hide resolved
- meta_include_prototype: false
- meta_scope: string.other.quoted.brackets.sql
- match: '\}'
scope: punctuation.definition.string.end.sql
pop: true
- include: string-interpolation

string-interpolation:
- meta_include_prototype: false
- match: '(#\{)([^\}]*)(\})'
scope: string.interpolated.sql
captures:
1: punctuation.definition.string.begin.sql
3: punctuation.definition.string.end.sql

regexps:
- match: /(?=\S.*/)
scope: punctuation.definition.string.begin.sql
push:
keith-hall marked this conversation as resolved.
Show resolved Hide resolved
- meta_include_prototype: false
- meta_scope: string.regexp.sql
- match: /
scope: punctuation.definition.string.end.sql
pop: true
- include: string-interpolation
- match: \\/
scope: constant.character.escape.slash.sql

operators:
- meta_append: true
- match: \|\|
scope: keyword.operator.concatenation.sql

types:
- match: |-
(?xi)

# normal stuff, capture 1
\b(bigint|bigserial|bit|bool|boolean|box|bytea|cidr|circle|date|datetime|double\s+precision|enum|inet|int|integer|line|longtext|lseg|macaddr|money|ntext|oid|path|point|polygon|real|serial|smallint|sysdate|sysname|text|tinytext)\b

# numeric suffix, capture 2 + 3i
|\b(bit\svarying|character\s+(?:varying)?|tinyint|var\schar|float|interval)\((\d+)\)

# optional numeric suffix, capture 4 + 5i
|\b(char|number|nvarchar|varbinary|varchar\d?)\b(?:\((\d+)\))?

# special case, capture 6 + 7i + 8i
|\b(numeric|decimal)\b(?:\((\d+),(\d+)\))?

# special case, captures 9, 10i, 11
|\b(times?)\b(?:\((\d+)\))?(\swith(?:out)?\s+time\s+zone\b)?

# special case, captures 12, 13, 14i, 15
|\b(timestamp)(?:(s|tz))?\b(?:\((\d+)\))?(\s(with|without)\s+time\s+zone\b)?


captures:
1: storage.type.sql
2: storage.type.sql
3: constant.numeric.sql
4: storage.type.sql
5: constant.numeric.sql
6: storage.type.sql
7: constant.numeric.sql
8: constant.numeric.sql
9: storage.type.sql
10: constant.numeric.sql
11: storage.type.sql
12: storage.type.sql
13: storage.type.sql
14: constant.numeric.sql
15: storage.type.sql

inside-number-sign-comment:
- meta_include_prototype: false
- meta_scope: comment.line.number-sign.sql
- match: \n
pop: true

expressions:
- meta_append: true
- match: (?i)\b(CONCATENATE|CONVERT|LOWER|SUBSTRING|TRANSLATE|TRIM|UPPER)\b
scope: support.function.string.sql

statements:
- meta_append: true
- match: (?i:\b(begin(\s+work)?|start\s+transaction|commit(\s+work)?|rollback(\s+work)?)\b)
scope: keyword.other.LUW.sql
Loading