Skip to content

Commit

Permalink
[SQL] [MySQL] support for REPLACE (#4117)
Browse files Browse the repository at this point in the history
This commit adds support 

1. for REPLACE
   see: https://dev.mysql.com/doc/refman/8.4/en/replace.html

2. for INSERT without INTO
   see: https://dev.mysql.com/doc/refman/8.4/en/insert.html
  • Loading branch information
keith-hall authored Dec 18, 2024
1 parent 27e290d commit 8da5d88
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
5 changes: 4 additions & 1 deletion SQL/MySQL.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,10 @@ contexts:
dml-statements:
- meta_append: true
- include: index-hint-lists
- match: \b(?i:insert(\s+(?:ignore\s+)?into)?)\b
- match: \b(?i:insert(?:\s+ignore)?(?:\s+into)?)\b
scope: keyword.other.dml.sql
push: expect-table-name
- match: \b(?i:replace\s+(?:into)?)\b
scope: keyword.other.dml.sql
push: expect-table-name
- match: \b(?i:limit)\b
Expand Down
32 changes: 32 additions & 0 deletions SQL/tests/syntax/syntax_test_mysql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4651,3 +4651,35 @@ EXPLAIN ANALYZE FORMAT=TREE SELECT * FROM t3 WHERE pk > 17;
CREATE USER 'read' IDENTIFIED BY 'toor';
GRANT SELECT ON * . * TO 'read';
FLUSH PRIVILEGES;


REPLACE INTO test2 VALUES (1, 'Old', '2014-08-20 18:47:00');
-- ^^^^^^^^^ keyword.other.dml
-- ^^^^^ meta.table-name
-- ^^^^^^ keyword.other
REPLACE test2 VALUES (1, 'Old', '2014-08-20 18:47:00');
-- ^^^^ keyword.other.dml
-- ^^^^^ meta.table-name
-- ^^^^^^ keyword.other

INSERT IGNORE INTO users_partners (uid,pid) VALUES (1,1);
-- ^^^^^^^^^^^^^^^ keyword.other.dml
-- ^^^^^^^^^^^^^^ meta.table-name
-- ^^^^^^^^^ meta.group
-- ^ punctuation.section.group.begin
-- ^^^ meta.column-name
-- ^ punctuation.separator.sequence
-- ^^^ meta.column-name
-- ^ punctuation.section.group.end
-- ^^^^^^ keyword.other
-- ^^^^^ meta.group
-- ^ punctuation.section.group.begin
-- ^ meta.number.integer.decimal constant.numeric.value
-- ^ punctuation.separator.sequence
-- ^ meta.number.integer.decimal constant.numeric.value
-- ^ punctuation.section.group.end
-- ^ punctuation.terminator.statement

INSERT IGNORE users_partners (uid,pid) VALUES (1,1);
-- ^^^^^^^^^^ keyword.other.dml
-- ^^^^^^^^^^^^^^ meta.table-name

0 comments on commit 8da5d88

Please sign in to comment.