Skip to content

Commit

Permalink
Add additional clauses/keywords to the insert statement
Browse files Browse the repository at this point in the history
  • Loading branch information
wishdev committed Mar 6, 2023
1 parent 1cb7c7a commit de17c23
Show file tree
Hide file tree
Showing 5 changed files with 161,002 additions and 155,536 deletions.
52 changes: 43 additions & 9 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,12 @@ module.exports = grammar({
keyword_preserve: _ => make_keyword("preserve"),
keyword_unsigned: _ => make_keyword("unsigned"),
keyword_zerofill: _ => make_keyword("zerofill"),
keyword_conflict: _ => make_keyword("conflict"),
keyword_do: _ => make_keyword("do"),
keyword_nothing: _ => make_keyword("nothing"),
keyword_high_priority: _ => make_keyword("high_priority"),
keyword_low_priority: _ => make_keyword("low_priority"),
keyword_delayed: _ => make_keyword("delayed"),

// Hive Keywords
keyword_external: _ => make_keyword("external"),
Expand Down Expand Up @@ -948,18 +954,48 @@ module.exports = grammar({
),

insert: $ => seq(
choice($.keyword_insert, $.keyword_replace),
$.keyword_into,
choice(
$.keyword_insert,
$.keyword_replace
),
optional(
choice(
$.keyword_low_priority,
$.keyword_delayed,
$.keyword_high_priority,
),
),
optional($.keyword_ignore),
optional($.keyword_into),
$.table_reference,
optional(
seq(
$.keyword_as,
field('table_alias', $._alias_identifier)
)
),
),
choice(
$._insert_values,
$._insert_set,
$._set_values,
),
optional(
seq(
$.keyword_on,
$.keyword_conflict,
optional(
seq(
$.keyword_do,
choice(
$.keyword_nothing,
seq(
$.keyword_update,
$._set_values,
optional($.where),
),
),
),
),
),
),
),

Expand All @@ -974,7 +1010,7 @@ module.exports = grammar({
),
),

_insert_set: $ => seq(
_set_values: $ => seq(
$.keyword_set,
comma_list($.assignment, true),
),
Expand All @@ -1000,17 +1036,15 @@ module.exports = grammar({
seq(
comma_list($.relation, true),
repeat($.join),
$.keyword_set,
comma_list($.assignment, true),
$._set_values,
optional($.where),
),
),

_postgres_update_statement: $ => prec(1,
seq(
$.relation,
$.keyword_set,
comma_list($.assignment, true),
$._set_values,
optional($.from),
),
),
Expand Down
203 changes: 147 additions & 56 deletions src/grammar.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit de17c23

Please sign in to comment.