From 7e578085f24bb75315ecf530c9812512263153a7 Mon Sep 17 00:00:00 2001 From: Keith Hall Date: Wed, 18 Dec 2024 20:04:32 +0200 Subject: [PATCH] [SQL] [MySQL] support for REPLACE https://dev.mysql.com/doc/refman/8.4/en/replace.html also support for INSERT without INTO https://dev.mysql.com/doc/refman/8.4/en/insert.html --- SQL/MySQL.sublime-syntax | 5 +++- SQL/tests/syntax/syntax_test_mysql.sql | 32 ++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/SQL/MySQL.sublime-syntax b/SQL/MySQL.sublime-syntax index 9357806dfe..6bec5d2a8b 100644 --- a/SQL/MySQL.sublime-syntax +++ b/SQL/MySQL.sublime-syntax @@ -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 diff --git a/SQL/tests/syntax/syntax_test_mysql.sql b/SQL/tests/syntax/syntax_test_mysql.sql index bc1ff92d5d..ff8a00c15e 100644 --- a/SQL/tests/syntax/syntax_test_mysql.sql +++ b/SQL/tests/syntax/syntax_test_mysql.sql @@ -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