refac #2

Merged
pleshevskiy merged 12 commits from refac into main 2023-03-16 13:22:15 +03:00
6 changed files with 1832 additions and 1623 deletions
Showing only changes of commit e4e1756164 - Show all commits

View file

@ -56,16 +56,16 @@ module.exports = grammar({
$._not_null, $._not_null,
$.keyword_null, $.keyword_null,
seq($.keyword_default, $._expression), seq($.keyword_default, $._expression),
// TODO: add index_parameters in UNIQUE, PRIMARY KEY
seq( seq(
$.keyword_unique, $.keyword_unique,
optional( optional(
seq($.keyword_nulls, optional($.keyword_not), $.keyword_distinct) seq($.keyword_nulls, optional($.keyword_not), $.keyword_distinct)
) )
) ),
$.keyword_primary_key
// TODO: CHECK // TODO: CHECK
// TODO: GENERATED // TODO: GENERATED
// TODO: UNIQUE
// TODO: PRIMARY KEY
// TODO: FOREIGN KEY // TODO: FOREIGN KEY
) )
// TODO: DEFERRABLE // TODO: DEFERRABLE
@ -195,6 +195,7 @@ module.exports = grammar({
keyword_nulls: (_) => mkKeyword("nulls"), keyword_nulls: (_) => mkKeyword("nulls"),
keyword_distinct: (_) => mkKeyword("distinct"), keyword_distinct: (_) => mkKeyword("distinct"),
keyword_unique: (_) => mkKeyword("unique"), keyword_unique: (_) => mkKeyword("unique"),
keyword_primary_key: (_) => seq(mkKeyword("primary"), mkKeyword("key")),
// References: https://www.postgresql.org/docs/15/datatype-xml.html // References: https://www.postgresql.org/docs/15/datatype-xml.html
keyword_xml: (_) => mkKeyword("xml"), keyword_xml: (_) => mkKeyword("xml"),
// References: https://www.postgresql.org/docs/15/datatype-uuid.html // References: https://www.postgresql.org/docs/15/datatype-uuid.html

View file

@ -284,6 +284,10 @@
] ]
} }
] ]
},
{
"type": "SYMBOL",
"name": "keyword_primary_key"
} }
] ]
} }
@ -993,6 +997,19 @@
"type": "PATTERN", "type": "PATTERN",
"value": "unique|UNIQUE" "value": "unique|UNIQUE"
}, },
"keyword_primary_key": {
"type": "SEQ",
"members": [
{
"type": "PATTERN",
"value": "primary|PRIMARY"
},
{
"type": "PATTERN",
"value": "key|KEY"
}
]
},
"keyword_xml": { "keyword_xml": {
"type": "PATTERN", "type": "PATTERN",
"value": "xml|XML" "value": "xml|XML"

View file

@ -73,6 +73,10 @@
"type": "keyword_nulls", "type": "keyword_nulls",
"named": true "named": true
}, },
{
"type": "keyword_primary_key",
"named": true
},
{ {
"type": "keyword_unique", "type": "keyword_unique",
"named": true "named": true
@ -321,6 +325,11 @@
"named": true, "named": true,
"fields": {} "fields": {}
}, },
{
"type": "keyword_primary_key",
"named": true,
"fields": {}
},
{ {
"type": "keyword_temporary", "type": "keyword_temporary",
"named": true, "named": true,

File diff suppressed because it is too large Load diff

View file

@ -172,6 +172,7 @@ create table foo (
Create a table with column constraints Create a table with column constraints
================================================================================ ================================================================================
create table foo ( create table foo (
id uuid primary key,
c1 text not null, c1 text not null,
c2 text null, c2 text null,
c3 text not null default 'hello' c3 text not null default 'hello'
@ -187,6 +188,13 @@ create table foo (
name: (identifier) name: (identifier)
) )
(column_definitions (column_definitions
(column_definition
name: (identifier)
datatype: (keyword_uuid)
(column_constraint
(keyword_primary_key)
)
)
(column_definition (column_definition
name: (identifier) name: (identifier)
datatype: (keyword_text) datatype: (keyword_text)
@ -223,6 +231,7 @@ create table foo (
Create a table with named column constraints Create a table with named column constraints
================================================================================ ================================================================================
create table foo ( create table foo (
id uuid constraint foo_pkey primary key,
c1 text constraint strong_c1 not null, c1 text constraint strong_c1 not null,
c2 text constraint weak_c2 null, c2 text constraint weak_c2 null,
c3 text constraint "c3 with power" not null constraint "c2 set default hello" default 'hello', c3 text constraint "c3 with power" not null constraint "c2 set default hello" default 'hello',
@ -239,6 +248,15 @@ create table foo (
name: (identifier) name: (identifier)
) )
(column_definitions (column_definitions
(column_definition
name: (identifier)
datatype: (keyword_uuid)
(column_constraint
(keyword_constraint)
name: (identifier)
(keyword_primary_key)
)
)
(column_definition (column_definition
name: (identifier) name: (identifier)
datatype: (keyword_text) datatype: (keyword_text)

Binary file not shown.