feat: pgsql collect column name (#216)

* feat(pgsql: collect column name): pgsql: collect column name

* feat(pgsql): repair column name's unit test and sql

* feat(pgsql): pgsql: collect expression's column

* feat(update column's collect of some expression): pgsql: update column's collect of some expression

---------

Co-authored-by: zhaoge <>
This commit is contained in:
XCynthia 2023-11-28 10:07:29 +08:00 committed by GitHub
parent 428d851913
commit db05cb3e4f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 21365 additions and 18524 deletions

View File

@ -295,6 +295,12 @@ iso_level:
| KW_REPEATABLE KW_READ
| KW_SERIALIZABLE;
opt_boolean_or_string_column:
KW_TRUE
| KW_FALSE
| KW_ON
| nonreservedword_or_sconst_column;
opt_boolean_or_string:
KW_TRUE
| KW_FALSE
@ -312,6 +318,8 @@ zone_value:
opt_encoding: sconst | KW_DEFAULT;
nonreservedword_or_sconst_column: nonreservedword_column | sconst;
nonreservedword_or_sconst: nonreservedword | sconst;
variableresetstmt: KW_RESET reset_rest;
@ -389,25 +397,23 @@ partition_cmd:
index_partition_cmd: KW_ATTACH KW_PARTITION qualified_name;
alter_table_cmd:
KW_ADD columnDef
| KW_ADD opt_if_not_exists? columnDef
| KW_ADD KW_COLUMN opt_if_not_exists columnDef
| KW_ALTER opt_column? colid alter_column_default
| KW_ALTER opt_column? colid KW_DROP KW_NOT KW_NULL
| KW_ALTER opt_column? colid KW_SET KW_NOT KW_NULL
| KW_ALTER opt_column? colid KW_DROP KW_EXPRESSION opt_if_exists?
| KW_ALTER opt_column? colid KW_SET KW_STATISTICS signediconst
| KW_ALTER opt_column? iconst KW_SET KW_STATISTICS signediconst
| KW_ALTER opt_column? colid KW_SET reloptions
| KW_ALTER opt_column? colid KW_RESET reloptions
| KW_ALTER opt_column? colid KW_SET KW_STORAGE colid
| KW_ALTER opt_column? colid KW_ADD KW_GENERATED generated_when KW_AS KW_IDENTITY
KW_ADD opt_column? opt_if_not_exists? columnDefCluase
| KW_ALTER opt_column? column_name alter_column_default
| KW_ALTER opt_column? column_name KW_DROP KW_NOT KW_NULL
| KW_ALTER opt_column? column_name KW_SET KW_NOT KW_NULL
| KW_ALTER opt_column? column_name KW_DROP KW_EXPRESSION opt_if_exists?
| KW_ALTER opt_column? column_name KW_SET KW_STATISTICS signediconst
| KW_ALTER opt_column? column_name KW_SET KW_STATISTICS signediconst
| KW_ALTER opt_column? column_name KW_SET reloptions
| KW_ALTER opt_column? column_name KW_RESET reloptions
| KW_ALTER opt_column? column_name KW_SET KW_STORAGE colid
| KW_ALTER opt_column? column_name KW_ADD KW_GENERATED generated_when KW_AS KW_IDENTITY
optparenthesizedseqoptlist?
| KW_ALTER opt_column? colid alter_identity_column_option_list
| KW_ALTER opt_column? colid KW_DROP KW_IDENTITY opt_if_exists?
| KW_DROP opt_column? opt_if_exists? colid opt_drop_behavior?
| KW_ALTER opt_column? colid opt_set_data? KW_TYPE typename opt_collate_clause? alter_using?
| KW_ALTER opt_column? colid alter_generic_options
| KW_ALTER opt_column? column_name alter_identity_column_option_list
| KW_ALTER opt_column? column_name KW_DROP KW_IDENTITY opt_if_exists?
| KW_DROP opt_column? opt_if_exists? column_name opt_drop_behavior?
| KW_ALTER opt_column? column_name opt_set_data? KW_TYPE typename opt_collate_clause? alter_using?
| KW_ALTER opt_column? column_name alter_generic_options
| KW_ADD tableconstraint
| KW_ALTER KW_CONSTRAINT name constraintattributespec
| KW_VALIDATE KW_CONSTRAINT name
@ -493,7 +499,7 @@ alter_type_cmd:
closeportalstmt: KW_CLOSE (cursor_name | KW_ALL);
copystmt:
KW_COPY opt_binary? qualified_name opt_column_list? copy_from opt_program? copy_file_name
KW_COPY opt_binary? table_name opt_column_list? copy_from opt_program? copy_file_name
copy_delimiter? opt_with? copy_options where_clause?
| KW_COPY OPEN_PAREN preparablestmt CLOSE_PAREN KW_TO opt_program? copy_file_name opt_with?
copy_options;
@ -547,7 +553,7 @@ copy_generic_opt_arg_list:
COMMA copy_generic_opt_arg_list_item
)*;
copy_generic_opt_arg_list_item: opt_boolean_or_string;
copy_generic_opt_arg_list_item: opt_boolean_or_string_column;
createstmt:
KW_CREATE opttemp? KW_TABLE opt_if_not_exists? table_name_create (
@ -582,13 +588,15 @@ tableelement: columnDef | tablelikeclause | tableconstraint;
typedtableelement: columnOptions | tableconstraint;
columnDef: colid typename create_generic_options? storageCluase? compressionCluase? (KW_COLLATE any_name)? (KW_WITH KW_OPTIONS)? colquallist;
columnDefCluase: column_name typename create_generic_options? storageCluase? compressionCluase? (KW_COLLATE any_name)? (KW_WITH KW_OPTIONS)? colquallist;
columnDef: column_name typename create_generic_options? storageCluase? compressionCluase? (KW_COLLATE any_name)? (KW_WITH KW_OPTIONS)? colquallist;
compressionCluase: KW_COMPRESSION colid;
storageCluase: KW_STORAGE (KW_PLAIN | KW_EXTERNAL | KW_EXTENDED | KW_MAIN | KW_DEFAULT | colid);
columnOptions: colid (KW_WITH KW_OPTIONS)? colquallist;
columnOptions: column_name (KW_WITH KW_OPTIONS)? colquallist;
colquallist: colconstraint*;
@ -662,9 +670,7 @@ opt_no_inherit: KW_NO KW_INHERIT;
opt_column_list: OPEN_PAREN columnlist CLOSE_PAREN;
columnlist: columnElem (COMMA columnElem)*;
columnElem: colid;
columnlist: column_name (COMMA column_name)*;
opt_c_include: KW_INCLUDE OPEN_PAREN columnlist CLOSE_PAREN;
@ -695,7 +701,7 @@ key_action:
KW_NO KW_ACTION
| KW_RESTRICT
| KW_CASCADE
| KW_SET (KW_NULL | KW_DEFAULT);
| KW_SET (KW_NULL | KW_DEFAULT) columnlist?;
optinherit: KW_INHERITS OPEN_PAREN qualified_name_list CLOSE_PAREN;
@ -707,7 +713,7 @@ partitionspec:
part_params: part_elem (COMMA part_elem)*;
part_elem:
colid opt_collate? opt_class?
column_name opt_collate? opt_class?
| func_expr_windowless opt_collate? opt_class?
| OPEN_PAREN a_expr CLOSE_PAREN opt_collate? opt_class?;
@ -773,7 +779,7 @@ seqoptelem:
| KW_MAXVALUE numericonly
| KW_MINVALUE numericonly
| KW_NO (KW_MAXVALUE | KW_MINVALUE | KW_CYCLE)
| KW_OWNED KW_BY any_name
| KW_OWNED KW_BY table_column_name
| KW_SEQUENCE KW_NAME any_name
| KW_START opt_with? numericonly
| KW_RESTART opt_with? numericonly?;
@ -1211,6 +1217,12 @@ object_type_name_on_any_name: KW_POLICY | KW_RULE | KW_TRIGGER;
any_name_list: any_name (COMMA any_name)*;
table_column_name: table_name DOT column_name;
relation_column_name: relation_name DOT column_name;
relation_name: colid attrs?;
any_name: colid attrs?;
attrs: (DOT attr_name)+;
@ -1224,13 +1236,14 @@ opt_restart_seqs: KW_CONTINUE KW_IDENTITY | KW_RESTART KW_IDENTITY;
commentstmt:
KW_COMMENT KW_ON object_type_any_name KW_IS comment_text
| KW_COMMENT KW_ON KW_COLUMN any_name KW_IS comment_text
| KW_COMMENT KW_ON KW_COLUMN relation_column_name KW_IS comment_text
| KW_COMMENT KW_ON object_type_name KW_IS comment_text
| KW_COMMENT KW_ON KW_TYPE typename KW_IS comment_text
| KW_COMMENT KW_ON KW_DOMAIN typename KW_IS comment_text
| KW_COMMENT KW_ON KW_AGGREGATE aggregate_with_argtypes KW_IS comment_text
| KW_COMMENT KW_ON KW_FUNCTION function_with_argtypes KW_IS comment_text
| KW_COMMENT KW_ON KW_OPERATOR operator_with_argtypes KW_IS comment_text
| KW_COMMENT KW_ON KW_CONSTRAINT name KW_ON table_name KW_IS comment_text
| KW_COMMENT KW_ON KW_CONSTRAINT name KW_ON KW_DOMAIN? any_name KW_IS comment_text
| KW_COMMENT KW_ON KW_POLICY name KW_ON any_name KW_IS comment_text
| KW_COMMENT KW_ON KW_RULE name KW_ON any_name KW_IS comment_text
@ -1247,7 +1260,7 @@ comment_text: sconst | KW_NULL;
seclabelstmt:
KW_SECURITY KW_LABEL opt_provider? KW_ON object_type_any_name KW_IS security_label
| KW_SECURITY KW_LABEL opt_provider? KW_ON KW_COLUMN any_name KW_IS security_label
| KW_SECURITY KW_LABEL opt_provider? KW_ON KW_COLUMN table_column_name KW_IS security_label
| KW_SECURITY KW_LABEL opt_provider? KW_ON object_type_name KW_IS security_label
| KW_SECURITY KW_LABEL opt_provider? KW_ON KW_TYPE typename KW_IS security_label
| KW_SECURITY KW_LABEL opt_provider? KW_ON KW_DOMAIN typename KW_IS security_label
@ -1411,7 +1424,7 @@ index_elem_options:
| opt_collate? any_name reloptions opt_asc_desc? opt_nulls_order?;
index_elem:
colid index_elem_options
column_name index_elem_options
| func_expr_windowless index_elem_options
| OPEN_PAREN a_expr CLOSE_PAREN index_elem_options;
@ -1552,7 +1565,7 @@ transform_type_list:
opt_definition: KW_WITH definition;
table_func_column: param_name func_type;
table_func_column: column_name func_type;
table_func_column_list:
table_func_column (COMMA table_func_column)*;
@ -1663,11 +1676,11 @@ renamestmt:
| KW_ALTER KW_MATERIALIZED KW_VIEW opt_if_exists? view_name KW_RENAME KW_TO view_name_create
| KW_ALTER KW_INDEX opt_if_exists? qualified_name KW_RENAME KW_TO name
| KW_ALTER KW_FOREIGN KW_TABLE opt_if_exists? relation_expr KW_RENAME KW_TO table_name_create
| KW_ALTER KW_TABLE opt_if_exists? relation_expr KW_RENAME opt_column? name KW_TO name
| KW_ALTER KW_VIEW opt_if_exists? view_name KW_RENAME opt_column? name KW_TO name
| KW_ALTER KW_MATERIALIZED KW_VIEW opt_if_exists? view_name KW_RENAME opt_column? name KW_TO name
| KW_ALTER KW_TABLE opt_if_exists? relation_expr KW_RENAME opt_column? column_name KW_TO column_name_create
| KW_ALTER KW_VIEW opt_if_exists? view_name KW_RENAME opt_column? column_name KW_TO column_name_create
| KW_ALTER KW_MATERIALIZED KW_VIEW opt_if_exists? view_name KW_RENAME opt_column? column_name KW_TO column_name_create
| KW_ALTER KW_TABLE opt_if_exists? relation_expr KW_RENAME KW_CONSTRAINT name KW_TO name
| KW_ALTER KW_FOREIGN KW_TABLE opt_if_exists? relation_expr KW_RENAME opt_column? name KW_TO name
| KW_ALTER KW_FOREIGN KW_TABLE opt_if_exists? relation_expr KW_RENAME opt_column? column_name KW_TO column_name_create
| KW_ALTER KW_RULE name KW_ON qualified_name KW_RENAME KW_TO name
| KW_ALTER KW_TRIGGER name KW_ON qualified_name KW_RENAME KW_TO name
| KW_ALTER KW_EVENT KW_TRIGGER name KW_RENAME KW_TO name
@ -1964,7 +1977,7 @@ cluster_index_specification: KW_USING name;
vacuumstmt:
KW_VACUUM opt_full? opt_freeze? opt_verbose? opt_analyze? opt_vacuum_relation_list?
| KW_VACUUM OPEN_PAREN vac_analyze_option_list CLOSE_PAREN opt_vacuum_relation_list?;
| KW_VACUUM (OPEN_PAREN vac_analyze_option_list CLOSE_PAREN)? opt_vacuum_relation_list?;
analyzestmt:
analyze_keyword opt_verbose? opt_vacuum_relation_list?
@ -1990,9 +2003,9 @@ opt_full: KW_FULL;
opt_freeze: KW_FREEZE;
opt_name_list: OPEN_PAREN name_list CLOSE_PAREN;
opt_name_list: OPEN_PAREN columnlist CLOSE_PAREN;
vacuum_relation: qualified_name opt_name_list?;
vacuum_relation: table_name opt_name_list?;
vacuum_relation_list: vacuum_relation (COMMA vacuum_relation)*;
@ -2053,19 +2066,16 @@ insertstmt:
insert_target: table_name (KW_AS colid)?;
insert_rest:
selectstmt
| KW_OVERRIDING override_kind KW_VALUE selectstmt
| OPEN_PAREN insert_column_list CLOSE_PAREN (
(OPEN_PAREN insert_column_list CLOSE_PAREN)? (
KW_OVERRIDING override_kind KW_VALUE
)? selectstmt
| KW_DEFAULT KW_VALUES;
)? (default_values_or_values | selectstmt);
override_kind: KW_USER | KW_SYSTEM;
insert_column_list:
insert_column_item (COMMA insert_column_item)*;
insert_column_item: colid opt_indirection;
insert_column_item: column_name opt_indirection;
opt_on_conflict:
KW_ON KW_CONFLICT opt_conf_expr? KW_DO (
@ -2110,7 +2120,7 @@ set_clause:
set_target EQUAL a_expr
| OPEN_PAREN set_target_list CLOSE_PAREN EQUAL (KW_ROW? a_expr | OPEN_PAREN select_clause CLOSE_PAREN);
set_target: colid opt_indirection;
set_target: column_name opt_indirection;
set_target_list: set_target (COMMA set_target)*;
@ -2184,9 +2194,9 @@ common_table_expr:
name opt_name_list? KW_AS opt_materialized? OPEN_PAREN preparablestmt CLOSE_PAREN search_cluase? cycle_cluase?;
search_cluase:
KW_SEARCH (KW_BREADTH | KW_DEPTH) KW_FIRST KW_BY name_list KW_SET name;
KW_SEARCH (KW_BREADTH | KW_DEPTH) KW_FIRST KW_BY columnlist KW_SET column_name;
cycle_cluase: KW_CYCLE name_list KW_SET name KW_TO name KW_DEFAULT name KW_USING name;
cycle_cluase: KW_CYCLE columnlist KW_SET column_name (KW_TO name KW_DEFAULT name)? KW_USING column_name;
opt_materialized: KW_MATERIALIZED | KW_NOT KW_MATERIALIZED;
@ -2217,7 +2227,7 @@ sort_clause: KW_ORDER KW_BY sortby_list;
sortby_list: sortby (COMMA sortby)*;
sortby:
a_expr (KW_USING qual_all_op | opt_asc_desc)? opt_nulls_order?;
column_expr_noparen (KW_USING qual_all_op | opt_asc_desc)? opt_nulls_order?;
select_limit:
limit_clause offset_clause?
@ -2258,17 +2268,18 @@ group_clause: KW_GROUP KW_BY group_by_list;
group_by_list: group_by_item (COMMA group_by_item)*;
group_by_item:
a_expr
column_expr_noparen
| empty_grouping_set
| cube_clause
| rollup_clause
| grouping_sets_clause;
| grouping_sets_clause
| OPEN_PAREN column_expr_list_noparen CLOSE_PAREN;
empty_grouping_set: OPEN_PAREN CLOSE_PAREN;
rollup_clause: KW_ROLLUP OPEN_PAREN expr_list CLOSE_PAREN;
rollup_clause: KW_ROLLUP OPEN_PAREN column_expr_list_noparen CLOSE_PAREN;
cube_clause: KW_CUBE OPEN_PAREN expr_list CLOSE_PAREN;
cube_clause: KW_CUBE OPEN_PAREN column_expr_list_noparen CLOSE_PAREN;
grouping_sets_clause:
KW_GROUPING KW_SETS OPEN_PAREN group_by_list CLOSE_PAREN;
@ -2328,7 +2339,7 @@ func_alias_clause:
join_type: (KW_FULL | KW_LEFT | KW_RIGHT | KW_INNER) KW_OUTER?;
join_qual: KW_USING OPEN_PAREN name_list CLOSE_PAREN | KW_ON a_expr;
join_qual: KW_USING OPEN_PAREN columnlist CLOSE_PAREN | KW_ON a_expr;
relation_expr:
KW_ONLY? table_name STAR? columnlist? where_clause?
@ -2370,7 +2381,7 @@ opt_col_def_list:
opt_ordinality: KW_WITH KW_ORDINALITY;
where_clause: KW_WHERE a_expr;
where_clause: KW_WHERE column_expr_noparen;
where_or_current_clause:
KW_WHERE (KW_CURRENT KW_OF cursor_name | a_expr);
@ -2834,9 +2845,13 @@ subquery_Op:
expr_list: a_expr (COMMA a_expr)*;
column_expr_list_noparen: column_expr_noparen (COMMA column_expr_noparen)*;
column_expr_list: column_expr (COMMA column_expr)*;
column_expr: columnElem | (OPEN_PAREN a_expr CLOSE_PAREN);
column_expr: column_name | (OPEN_PAREN a_expr CLOSE_PAREN);
column_expr_noparen: column_name | a_expr;
func_arg_list: func_arg_expr (COMMA func_arg_expr)*;
@ -2913,7 +2928,7 @@ opt_target_list: target_list;
target_list: target_el (COMMA target_el)*;
target_el:
a_expr (KW_AS collabel | identifier |) # target_label
column_expr_noparen (KW_AS collabel | identifier |) # target_label
| STAR # target_star;
qualified_name_list: qualified_name (COMMA qualified_name)*;
@ -2958,6 +2973,10 @@ procedure_name: type_function_name | colid indirection;
procedure_name_create: type_function_name | colid indirection;
column_name: colid;
column_name_create: colid;
name: colid;
attr_name: collabel;
@ -3044,6 +3063,8 @@ type_usual_name:
| plsql_unreserved_keyword
| type_func_name_keyword;
nonreservedword_column: column_name | type_func_name_keyword;
nonreservedword:
identifier
| unreserved_keyword
@ -3857,9 +3878,9 @@ opt_fetch_direction:
stmt_move: KW_MOVE opt_fetch_direction? cursor_variable SEMI;
mergestmt: with_clause? KW_MERGE KW_INTO (KW_ONLY)? table_name (STAR)? (KW_AS colid?)? KW_USING data_source KW_ON join_condition merge_when_clause+;
mergestmt: with_clause? KW_MERGE KW_INTO (KW_ONLY)? table_name (STAR)? (KW_AS? colid)? KW_USING data_source KW_ON join_condition merge_when_clause+;
data_source: (KW_ONLY)? table_name (STAR)? | ( select_no_parens | values_clause ) (KW_AS? colid)?;
data_source: ((KW_ONLY)? table_name (STAR)? | ( select_no_parens | values_clause ) )(KW_AS? colid)?;
join_condition: a_expr;
@ -3868,13 +3889,15 @@ merge_when_clause:
| KW_WHEN KW_NOT KW_MATCHED (KW_AND a_expr)? KW_THEN (merge_insert | KW_DO KW_NOTHING);
merge_insert:
KW_INSERT columnlist? (KW_OVERRIDING (KW_SYSTEM | KW_USER) KW_VALUE)? (KW_VALUES exprofdefaultlist | KW_DEFAULT KW_VALUES) ;
KW_INSERT (OPEN_PAREN columnlist CLOSE_PAREN)? (KW_OVERRIDING (KW_SYSTEM | KW_USER) KW_VALUE)? default_values_or_values ;
merge_update:
KW_UPDATE KW_SET (columnElem EQUAL exprofdefault
| columnlist EQUAL exprofdefaultlist)+
KW_UPDATE KW_SET (column_name EQUAL exprofdefault
| OPEN_PAREN columnlist CLOSE_PAREN EQUAL OPEN_PAREN exprofdefaultlist CLOSE_PAREN)+
;
default_values_or_values: KW_VALUES exprofdefaultlist | KW_DEFAULT KW_VALUES;
exprofdefaultlist: OPEN_PAREN exprofdefault (COMMA exprofdefault)* CLOSE_PAREN;
exprofdefault: sortby | KW_DEFAULT;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -48,9 +48,11 @@ import { Var_nameContext } from "./PostgreSQLParser";
import { Var_listContext } from "./PostgreSQLParser";
import { Var_valueContext } from "./PostgreSQLParser";
import { Iso_levelContext } from "./PostgreSQLParser";
import { Opt_boolean_or_string_columnContext } from "./PostgreSQLParser";
import { Opt_boolean_or_stringContext } from "./PostgreSQLParser";
import { Zone_valueContext } from "./PostgreSQLParser";
import { Opt_encodingContext } from "./PostgreSQLParser";
import { Nonreservedword_or_sconst_columnContext } from "./PostgreSQLParser";
import { Nonreservedword_or_sconstContext } from "./PostgreSQLParser";
import { VariableresetstmtContext } from "./PostgreSQLParser";
import { Reset_restContext } from "./PostgreSQLParser";
@ -114,6 +116,7 @@ import { TableelementlistContext } from "./PostgreSQLParser";
import { TypedtableelementlistContext } from "./PostgreSQLParser";
import { TableelementContext } from "./PostgreSQLParser";
import { TypedtableelementContext } from "./PostgreSQLParser";
import { ColumnDefCluaseContext } from "./PostgreSQLParser";
import { ColumnDefContext } from "./PostgreSQLParser";
import { CompressionCluaseContext } from "./PostgreSQLParser";
import { StorageCluaseContext } from "./PostgreSQLParser";
@ -133,7 +136,6 @@ import { ConstraintelemContext } from "./PostgreSQLParser";
import { Opt_no_inheritContext } from "./PostgreSQLParser";
import { Opt_column_listContext } from "./PostgreSQLParser";
import { ColumnlistContext } from "./PostgreSQLParser";
import { ColumnElemContext } from "./PostgreSQLParser";
import { Opt_c_includeContext } from "./PostgreSQLParser";
import { Key_matchContext } from "./PostgreSQLParser";
import { ExclusionconstraintlistContext } from "./PostgreSQLParser";
@ -287,6 +289,9 @@ import { Object_type_any_nameContext } from "./PostgreSQLParser";
import { Object_type_nameContext } from "./PostgreSQLParser";
import { Object_type_name_on_any_nameContext } from "./PostgreSQLParser";
import { Any_name_listContext } from "./PostgreSQLParser";
import { Table_column_nameContext } from "./PostgreSQLParser";
import { Relation_column_nameContext } from "./PostgreSQLParser";
import { Relation_nameContext } from "./PostgreSQLParser";
import { Any_nameContext } from "./PostgreSQLParser";
import { AttrsContext } from "./PostgreSQLParser";
import { Type_name_listContext } from "./PostgreSQLParser";
@ -668,8 +673,10 @@ import { Qual_opContext } from "./PostgreSQLParser";
import { Qual_all_opContext } from "./PostgreSQLParser";
import { Subquery_OpContext } from "./PostgreSQLParser";
import { Expr_listContext } from "./PostgreSQLParser";
import { Column_expr_list_noparenContext } from "./PostgreSQLParser";
import { Column_expr_listContext } from "./PostgreSQLParser";
import { Column_exprContext } from "./PostgreSQLParser";
import { Column_expr_noparenContext } from "./PostgreSQLParser";
import { Func_arg_listContext } from "./PostgreSQLParser";
import { Func_arg_exprContext } from "./PostgreSQLParser";
import { Type_listContext } from "./PostgreSQLParser";
@ -717,6 +724,8 @@ import { Routine_name_createContext } from "./PostgreSQLParser";
import { Routine_nameContext } from "./PostgreSQLParser";
import { Procedure_nameContext } from "./PostgreSQLParser";
import { Procedure_name_createContext } from "./PostgreSQLParser";
import { Column_nameContext } from "./PostgreSQLParser";
import { Column_name_createContext } from "./PostgreSQLParser";
import { NameContext } from "./PostgreSQLParser";
import { Attr_nameContext } from "./PostgreSQLParser";
import { File_nameContext } from "./PostgreSQLParser";
@ -742,6 +751,7 @@ import { Exclude_elementContext } from "./PostgreSQLParser";
import { Index_paramentersContext } from "./PostgreSQLParser";
import { Type_function_nameContext } from "./PostgreSQLParser";
import { Type_usual_nameContext } from "./PostgreSQLParser";
import { Nonreservedword_columnContext } from "./PostgreSQLParser";
import { NonreservedwordContext } from "./PostgreSQLParser";
import { CollabelContext } from "./PostgreSQLParser";
import { IdentifierContext } from "./PostgreSQLParser";
@ -845,6 +855,7 @@ import { Join_conditionContext } from "./PostgreSQLParser";
import { Merge_when_clauseContext } from "./PostgreSQLParser";
import { Merge_insertContext } from "./PostgreSQLParser";
import { Merge_updateContext } from "./PostgreSQLParser";
import { Default_values_or_valuesContext } from "./PostgreSQLParser";
import { ExprofdefaultlistContext } from "./PostgreSQLParser";
import { ExprofdefaultContext } from "./PostgreSQLParser";
import { Stmt_closeContext } from "./PostgreSQLParser";
@ -1394,6 +1405,17 @@ export interface PostgreSQLParserListener extends ParseTreeListener {
*/
exitIso_level?: (ctx: Iso_levelContext) => void;
/**
* Enter a parse tree produced by `PostgreSQLParser.opt_boolean_or_string_column`.
* @param ctx the parse tree
*/
enterOpt_boolean_or_string_column?: (ctx: Opt_boolean_or_string_columnContext) => void;
/**
* Exit a parse tree produced by `PostgreSQLParser.opt_boolean_or_string_column`.
* @param ctx the parse tree
*/
exitOpt_boolean_or_string_column?: (ctx: Opt_boolean_or_string_columnContext) => void;
/**
* Enter a parse tree produced by `PostgreSQLParser.opt_boolean_or_string`.
* @param ctx the parse tree
@ -1427,6 +1449,17 @@ export interface PostgreSQLParserListener extends ParseTreeListener {
*/
exitOpt_encoding?: (ctx: Opt_encodingContext) => void;
/**
* Enter a parse tree produced by `PostgreSQLParser.nonreservedword_or_sconst_column`.
* @param ctx the parse tree
*/
enterNonreservedword_or_sconst_column?: (ctx: Nonreservedword_or_sconst_columnContext) => void;
/**
* Exit a parse tree produced by `PostgreSQLParser.nonreservedword_or_sconst_column`.
* @param ctx the parse tree
*/
exitNonreservedword_or_sconst_column?: (ctx: Nonreservedword_or_sconst_columnContext) => void;
/**
* Enter a parse tree produced by `PostgreSQLParser.nonreservedword_or_sconst`.
* @param ctx the parse tree
@ -2120,6 +2153,17 @@ export interface PostgreSQLParserListener extends ParseTreeListener {
*/
exitTypedtableelement?: (ctx: TypedtableelementContext) => void;
/**
* Enter a parse tree produced by `PostgreSQLParser.columnDefCluase`.
* @param ctx the parse tree
*/
enterColumnDefCluase?: (ctx: ColumnDefCluaseContext) => void;
/**
* Exit a parse tree produced by `PostgreSQLParser.columnDefCluase`.
* @param ctx the parse tree
*/
exitColumnDefCluase?: (ctx: ColumnDefCluaseContext) => void;
/**
* Enter a parse tree produced by `PostgreSQLParser.columnDef`.
* @param ctx the parse tree
@ -2329,17 +2373,6 @@ export interface PostgreSQLParserListener extends ParseTreeListener {
*/
exitColumnlist?: (ctx: ColumnlistContext) => void;
/**
* Enter a parse tree produced by `PostgreSQLParser.columnElem`.
* @param ctx the parse tree
*/
enterColumnElem?: (ctx: ColumnElemContext) => void;
/**
* Exit a parse tree produced by `PostgreSQLParser.columnElem`.
* @param ctx the parse tree
*/
exitColumnElem?: (ctx: ColumnElemContext) => void;
/**
* Enter a parse tree produced by `PostgreSQLParser.opt_c_include`.
* @param ctx the parse tree
@ -4023,6 +4056,39 @@ export interface PostgreSQLParserListener extends ParseTreeListener {
*/
exitAny_name_list?: (ctx: Any_name_listContext) => void;
/**
* Enter a parse tree produced by `PostgreSQLParser.table_column_name`.
* @param ctx the parse tree
*/
enterTable_column_name?: (ctx: Table_column_nameContext) => void;
/**
* Exit a parse tree produced by `PostgreSQLParser.table_column_name`.
* @param ctx the parse tree
*/
exitTable_column_name?: (ctx: Table_column_nameContext) => void;
/**
* Enter a parse tree produced by `PostgreSQLParser.relation_column_name`.
* @param ctx the parse tree
*/
enterRelation_column_name?: (ctx: Relation_column_nameContext) => void;
/**
* Exit a parse tree produced by `PostgreSQLParser.relation_column_name`.
* @param ctx the parse tree
*/
exitRelation_column_name?: (ctx: Relation_column_nameContext) => void;
/**
* Enter a parse tree produced by `PostgreSQLParser.relation_name`.
* @param ctx the parse tree
*/
enterRelation_name?: (ctx: Relation_nameContext) => void;
/**
* Exit a parse tree produced by `PostgreSQLParser.relation_name`.
* @param ctx the parse tree
*/
exitRelation_name?: (ctx: Relation_nameContext) => void;
/**
* Enter a parse tree produced by `PostgreSQLParser.any_name`.
* @param ctx the parse tree
@ -8214,6 +8280,17 @@ export interface PostgreSQLParserListener extends ParseTreeListener {
*/
exitExpr_list?: (ctx: Expr_listContext) => void;
/**
* Enter a parse tree produced by `PostgreSQLParser.column_expr_list_noparen`.
* @param ctx the parse tree
*/
enterColumn_expr_list_noparen?: (ctx: Column_expr_list_noparenContext) => void;
/**
* Exit a parse tree produced by `PostgreSQLParser.column_expr_list_noparen`.
* @param ctx the parse tree
*/
exitColumn_expr_list_noparen?: (ctx: Column_expr_list_noparenContext) => void;
/**
* Enter a parse tree produced by `PostgreSQLParser.column_expr_list`.
* @param ctx the parse tree
@ -8236,6 +8313,17 @@ export interface PostgreSQLParserListener extends ParseTreeListener {
*/
exitColumn_expr?: (ctx: Column_exprContext) => void;
/**
* Enter a parse tree produced by `PostgreSQLParser.column_expr_noparen`.
* @param ctx the parse tree
*/
enterColumn_expr_noparen?: (ctx: Column_expr_noparenContext) => void;
/**
* Exit a parse tree produced by `PostgreSQLParser.column_expr_noparen`.
* @param ctx the parse tree
*/
exitColumn_expr_noparen?: (ctx: Column_expr_noparenContext) => void;
/**
* Enter a parse tree produced by `PostgreSQLParser.func_arg_list`.
* @param ctx the parse tree
@ -8753,6 +8841,28 @@ export interface PostgreSQLParserListener extends ParseTreeListener {
*/
exitProcedure_name_create?: (ctx: Procedure_name_createContext) => void;
/**
* Enter a parse tree produced by `PostgreSQLParser.column_name`.
* @param ctx the parse tree
*/
enterColumn_name?: (ctx: Column_nameContext) => void;
/**
* Exit a parse tree produced by `PostgreSQLParser.column_name`.
* @param ctx the parse tree
*/
exitColumn_name?: (ctx: Column_nameContext) => void;
/**
* Enter a parse tree produced by `PostgreSQLParser.column_name_create`.
* @param ctx the parse tree
*/
enterColumn_name_create?: (ctx: Column_name_createContext) => void;
/**
* Exit a parse tree produced by `PostgreSQLParser.column_name_create`.
* @param ctx the parse tree
*/
exitColumn_name_create?: (ctx: Column_name_createContext) => void;
/**
* Enter a parse tree produced by `PostgreSQLParser.name`.
* @param ctx the parse tree
@ -9028,6 +9138,17 @@ export interface PostgreSQLParserListener extends ParseTreeListener {
*/
exitType_usual_name?: (ctx: Type_usual_nameContext) => void;
/**
* Enter a parse tree produced by `PostgreSQLParser.nonreservedword_column`.
* @param ctx the parse tree
*/
enterNonreservedword_column?: (ctx: Nonreservedword_columnContext) => void;
/**
* Exit a parse tree produced by `PostgreSQLParser.nonreservedword_column`.
* @param ctx the parse tree
*/
exitNonreservedword_column?: (ctx: Nonreservedword_columnContext) => void;
/**
* Enter a parse tree produced by `PostgreSQLParser.nonreservedword`.
* @param ctx the parse tree
@ -10161,6 +10282,17 @@ export interface PostgreSQLParserListener extends ParseTreeListener {
*/
exitMerge_update?: (ctx: Merge_updateContext) => void;
/**
* Enter a parse tree produced by `PostgreSQLParser.default_values_or_values`.
* @param ctx the parse tree
*/
enterDefault_values_or_values?: (ctx: Default_values_or_valuesContext) => void;
/**
* Exit a parse tree produced by `PostgreSQLParser.default_values_or_values`.
* @param ctx the parse tree
*/
exitDefault_values_or_values?: (ctx: Default_values_or_valuesContext) => void;
/**
* Enter a parse tree produced by `PostgreSQLParser.exprofdefaultlist`.
* @param ctx the parse tree

View File

@ -48,9 +48,11 @@ import { Var_nameContext } from "./PostgreSQLParser";
import { Var_listContext } from "./PostgreSQLParser";
import { Var_valueContext } from "./PostgreSQLParser";
import { Iso_levelContext } from "./PostgreSQLParser";
import { Opt_boolean_or_string_columnContext } from "./PostgreSQLParser";
import { Opt_boolean_or_stringContext } from "./PostgreSQLParser";
import { Zone_valueContext } from "./PostgreSQLParser";
import { Opt_encodingContext } from "./PostgreSQLParser";
import { Nonreservedword_or_sconst_columnContext } from "./PostgreSQLParser";
import { Nonreservedword_or_sconstContext } from "./PostgreSQLParser";
import { VariableresetstmtContext } from "./PostgreSQLParser";
import { Reset_restContext } from "./PostgreSQLParser";
@ -114,6 +116,7 @@ import { TableelementlistContext } from "./PostgreSQLParser";
import { TypedtableelementlistContext } from "./PostgreSQLParser";
import { TableelementContext } from "./PostgreSQLParser";
import { TypedtableelementContext } from "./PostgreSQLParser";
import { ColumnDefCluaseContext } from "./PostgreSQLParser";
import { ColumnDefContext } from "./PostgreSQLParser";
import { CompressionCluaseContext } from "./PostgreSQLParser";
import { StorageCluaseContext } from "./PostgreSQLParser";
@ -133,7 +136,6 @@ import { ConstraintelemContext } from "./PostgreSQLParser";
import { Opt_no_inheritContext } from "./PostgreSQLParser";
import { Opt_column_listContext } from "./PostgreSQLParser";
import { ColumnlistContext } from "./PostgreSQLParser";
import { ColumnElemContext } from "./PostgreSQLParser";
import { Opt_c_includeContext } from "./PostgreSQLParser";
import { Key_matchContext } from "./PostgreSQLParser";
import { ExclusionconstraintlistContext } from "./PostgreSQLParser";
@ -287,6 +289,9 @@ import { Object_type_any_nameContext } from "./PostgreSQLParser";
import { Object_type_nameContext } from "./PostgreSQLParser";
import { Object_type_name_on_any_nameContext } from "./PostgreSQLParser";
import { Any_name_listContext } from "./PostgreSQLParser";
import { Table_column_nameContext } from "./PostgreSQLParser";
import { Relation_column_nameContext } from "./PostgreSQLParser";
import { Relation_nameContext } from "./PostgreSQLParser";
import { Any_nameContext } from "./PostgreSQLParser";
import { AttrsContext } from "./PostgreSQLParser";
import { Type_name_listContext } from "./PostgreSQLParser";
@ -668,8 +673,10 @@ import { Qual_opContext } from "./PostgreSQLParser";
import { Qual_all_opContext } from "./PostgreSQLParser";
import { Subquery_OpContext } from "./PostgreSQLParser";
import { Expr_listContext } from "./PostgreSQLParser";
import { Column_expr_list_noparenContext } from "./PostgreSQLParser";
import { Column_expr_listContext } from "./PostgreSQLParser";
import { Column_exprContext } from "./PostgreSQLParser";
import { Column_expr_noparenContext } from "./PostgreSQLParser";
import { Func_arg_listContext } from "./PostgreSQLParser";
import { Func_arg_exprContext } from "./PostgreSQLParser";
import { Type_listContext } from "./PostgreSQLParser";
@ -717,6 +724,8 @@ import { Routine_name_createContext } from "./PostgreSQLParser";
import { Routine_nameContext } from "./PostgreSQLParser";
import { Procedure_nameContext } from "./PostgreSQLParser";
import { Procedure_name_createContext } from "./PostgreSQLParser";
import { Column_nameContext } from "./PostgreSQLParser";
import { Column_name_createContext } from "./PostgreSQLParser";
import { NameContext } from "./PostgreSQLParser";
import { Attr_nameContext } from "./PostgreSQLParser";
import { File_nameContext } from "./PostgreSQLParser";
@ -742,6 +751,7 @@ import { Exclude_elementContext } from "./PostgreSQLParser";
import { Index_paramentersContext } from "./PostgreSQLParser";
import { Type_function_nameContext } from "./PostgreSQLParser";
import { Type_usual_nameContext } from "./PostgreSQLParser";
import { Nonreservedword_columnContext } from "./PostgreSQLParser";
import { NonreservedwordContext } from "./PostgreSQLParser";
import { CollabelContext } from "./PostgreSQLParser";
import { IdentifierContext } from "./PostgreSQLParser";
@ -845,6 +855,7 @@ import { Join_conditionContext } from "./PostgreSQLParser";
import { Merge_when_clauseContext } from "./PostgreSQLParser";
import { Merge_insertContext } from "./PostgreSQLParser";
import { Merge_updateContext } from "./PostgreSQLParser";
import { Default_values_or_valuesContext } from "./PostgreSQLParser";
import { ExprofdefaultlistContext } from "./PostgreSQLParser";
import { ExprofdefaultContext } from "./PostgreSQLParser";
import { Stmt_closeContext } from "./PostgreSQLParser";
@ -1207,6 +1218,13 @@ export interface PostgreSQLParserVisitor<Result> extends ParseTreeVisitor<Result
*/
visitIso_level?: (ctx: Iso_levelContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.opt_boolean_or_string_column`.
* @param ctx the parse tree
* @return the visitor result
*/
visitOpt_boolean_or_string_column?: (ctx: Opt_boolean_or_string_columnContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.opt_boolean_or_string`.
* @param ctx the parse tree
@ -1228,6 +1246,13 @@ export interface PostgreSQLParserVisitor<Result> extends ParseTreeVisitor<Result
*/
visitOpt_encoding?: (ctx: Opt_encodingContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.nonreservedword_or_sconst_column`.
* @param ctx the parse tree
* @return the visitor result
*/
visitNonreservedword_or_sconst_column?: (ctx: Nonreservedword_or_sconst_columnContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.nonreservedword_or_sconst`.
* @param ctx the parse tree
@ -1669,6 +1694,13 @@ export interface PostgreSQLParserVisitor<Result> extends ParseTreeVisitor<Result
*/
visitTypedtableelement?: (ctx: TypedtableelementContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.columnDefCluase`.
* @param ctx the parse tree
* @return the visitor result
*/
visitColumnDefCluase?: (ctx: ColumnDefCluaseContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.columnDef`.
* @param ctx the parse tree
@ -1802,13 +1834,6 @@ export interface PostgreSQLParserVisitor<Result> extends ParseTreeVisitor<Result
*/
visitColumnlist?: (ctx: ColumnlistContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.columnElem`.
* @param ctx the parse tree
* @return the visitor result
*/
visitColumnElem?: (ctx: ColumnElemContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.opt_c_include`.
* @param ctx the parse tree
@ -2880,6 +2905,27 @@ export interface PostgreSQLParserVisitor<Result> extends ParseTreeVisitor<Result
*/
visitAny_name_list?: (ctx: Any_name_listContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.table_column_name`.
* @param ctx the parse tree
* @return the visitor result
*/
visitTable_column_name?: (ctx: Table_column_nameContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.relation_column_name`.
* @param ctx the parse tree
* @return the visitor result
*/
visitRelation_column_name?: (ctx: Relation_column_nameContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.relation_name`.
* @param ctx the parse tree
* @return the visitor result
*/
visitRelation_name?: (ctx: Relation_nameContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.any_name`.
* @param ctx the parse tree
@ -5547,6 +5593,13 @@ export interface PostgreSQLParserVisitor<Result> extends ParseTreeVisitor<Result
*/
visitExpr_list?: (ctx: Expr_listContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.column_expr_list_noparen`.
* @param ctx the parse tree
* @return the visitor result
*/
visitColumn_expr_list_noparen?: (ctx: Column_expr_list_noparenContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.column_expr_list`.
* @param ctx the parse tree
@ -5561,6 +5614,13 @@ export interface PostgreSQLParserVisitor<Result> extends ParseTreeVisitor<Result
*/
visitColumn_expr?: (ctx: Column_exprContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.column_expr_noparen`.
* @param ctx the parse tree
* @return the visitor result
*/
visitColumn_expr_noparen?: (ctx: Column_expr_noparenContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.func_arg_list`.
* @param ctx the parse tree
@ -5890,6 +5950,20 @@ export interface PostgreSQLParserVisitor<Result> extends ParseTreeVisitor<Result
*/
visitProcedure_name_create?: (ctx: Procedure_name_createContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.column_name`.
* @param ctx the parse tree
* @return the visitor result
*/
visitColumn_name?: (ctx: Column_nameContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.column_name_create`.
* @param ctx the parse tree
* @return the visitor result
*/
visitColumn_name_create?: (ctx: Column_name_createContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.name`.
* @param ctx the parse tree
@ -6065,6 +6139,13 @@ export interface PostgreSQLParserVisitor<Result> extends ParseTreeVisitor<Result
*/
visitType_usual_name?: (ctx: Type_usual_nameContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.nonreservedword_column`.
* @param ctx the parse tree
* @return the visitor result
*/
visitNonreservedword_column?: (ctx: Nonreservedword_columnContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.nonreservedword`.
* @param ctx the parse tree
@ -6786,6 +6867,13 @@ export interface PostgreSQLParserVisitor<Result> extends ParseTreeVisitor<Result
*/
visitMerge_update?: (ctx: Merge_updateContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.default_values_or_values`.
* @param ctx the parse tree
* @return the visitor result
*/
visitDefault_values_or_values?: (ctx: Default_values_or_valuesContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.exprofdefaultlist`.
* @param ctx the parse tree

View File

@ -33,6 +33,8 @@ export default class PostgresSQL extends BasicParser<
PostgreSQLParser.RULE_database_name, // database name
PostgreSQLParser.RULE_procedure_name_create, // procedure name that will be created
PostgreSQLParser.RULE_procedure_name, // procedure name
PostgreSQLParser.RULE_column_name_create, // column name that will be created
PostgreSQLParser.RULE_column_name, // column name
]);
protected get splitListener() {
@ -105,6 +107,14 @@ export default class PostgresSQL extends BasicParser<
syntaxContextType = SyntaxContextType.PROCEDURE;
break;
}
case PostgreSQLParser.RULE_column_name_create: {
syntaxContextType = SyntaxContextType.COLUMN_CREATE;
break;
}
case PostgreSQLParser.RULE_column_name: {
syntaxContextType = SyntaxContextType.COLUMN;
break;
}
default:
break;
}

View File

@ -1,10 +1,10 @@
CREATE TABLE db. ();
CREATE TABLE db.s (column_name int) PARTITION BY LIST (column_name);
INSERT INTO db.tb ;
SELECT * FROM db. ;
ALTER TABLE db ;
ALTER TABLE db ALTER column_name DROP NOT NULL;
CREATE OR REPLACE VIEW db.v;
@ -28,4 +28,50 @@ DROP SCHEMA IF EXISTS sch;
ALTER SCHEMA name RENAME TO new_name;
ALTER FOREIGN TABLE table_name RENAME column_name TO new_column_name;
ALTER MATERIALIZED VIEW view_name RENAME COLUMN column_name TO new_column_name;
ALTER MATERIALIZED VIEW view_name ALTER column_name SET STATISTICS 45;
ALTER PUBLICATION name ADD TABLE table_name ( column_name);
ALTER SEQUENCE name OWNED BY table_name.column_name;
ALTER TABLE db RENAME column_name TO new_column_name;
ANALYZE table_name (column_name);
COMMENT ON COLUMN relation_name.column_name IS NULL;
COPY table_name (col_name, col_name2) FROM 'filename' WITH (FORCE_QUOTE (clumn_name));
CREATE FOREIGN TABLE table_name (column_name int) SERVER server_name;
CREATE FUNCTION name (int) RETURNS TABLE (column_name column_type) LANGUAGE lang_name;
CREATE INDEX ON table_name (column_name) INCLUDE (col_name1, col_name2);
CREATE MATERIALIZED VIEW table_name (col_name);
CREATE STATISTICS ON column_name FROM table_name;
CREATE TRIGGER name AFTER UPDATE OF column_name ON table_name EXECUTE FUNCTION function_name;
GRANT SELECT ( column_name) ON table_name TO role_specification;
INSERT INTO table_name (column_name) DEFAULT VALUES ON CONFLICT (index_column_name) DO UPDATE SET column_name_exp = DEFAULT;
MERGE INTO wines w USING wine_stock_changes s ON s.winename = w.winename WHEN NOT MATCHED AND stock_delta > 0 THEN INSERT (col_name) VALUES(s.winename, s.stock_delta);
REVOKE SELECT (co_name) ON table_name FROM PUBLIC;
SECURITY LABEL ON COLUMN tablename.columnname IS string_literal;
WITH with_query_name (col_name) AS (SELECT id FROM table_expression) SEARCH DEPTH FIRST BY column_name SET column_name CYCLE col_name SET col_name USING col_name SELECT;
UPDATE tablename SET columnname = a + b, (col1, col2) = (a+3, b+4);
VACUUM tablename (col1, col2);
SELECT * FROM db.tbs GROUP BY (col1, col2) ORDER BY col3;

View File

@ -52,7 +52,7 @@ describe('Postgre SQL Syntax Suggestion', () => {
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['db']);
});
test('Select table ', () => {
test('Select table', () => {
const pos: CaretPosition = {
lineNumber: 5,
column: 18,
@ -72,18 +72,44 @@ describe('Postgre SQL Syntax Suggestion', () => {
test('Create table ', () => {
const pos: CaretPosition = {
lineNumber: 1,
column: 17,
column: 18,
};
const pos1: CaretPosition = {
lineNumber: 1,
column: 31,
};
const pos2: CaretPosition = {
lineNumber: 1,
column: 67,
};
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const syntaxes1 = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos1.lineNumber),
pos1
)?.syntax;
const syntaxes2 = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos2.lineNumber),
pos2
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.TABLE_CREATE
);
const suggestion1 = syntaxes1?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN
);
const suggestion2 = syntaxes2?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN
);
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['db', '.']);
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['db', '.', 's']);
expect(suggestion1).not.toBeUndefined();
expect(suggestion1?.wordRanges.map((token) => token.text)).toEqual(['column_name']);
expect(suggestion2).not.toBeUndefined();
expect(suggestion2?.wordRanges.map((token) => token.text)).toEqual(['column_name']);
});
test('Create view ', () => {
@ -272,4 +298,668 @@ describe('Postgre SQL Syntax Suggestion', () => {
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['name']);
});
test('Alter Foreign Table With Column', () => {
const pos: CaretPosition = {
lineNumber: 31,
column: 50,
};
const posCreate: CaretPosition = {
lineNumber: 31,
column: 69,
};
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const syntaxesCreate = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, posCreate.lineNumber),
posCreate
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN
);
const suggestionCreate = syntaxesCreate?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN_CREATE
);
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['column_name']);
expect(suggestionCreate).not.toBeUndefined();
expect(suggestionCreate?.wordRanges.map((token) => token.text)).toEqual([
'new_column_name',
]);
});
test('Alter MATERIALIZED VIEW With Column', () => {
const pos: CaretPosition = {
lineNumber: 33,
column: 60,
};
const posCreate: CaretPosition = {
lineNumber: 33,
column: 79,
};
const posAction: CaretPosition = {
lineNumber: 35,
column: 52,
};
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const syntaxesCreate = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, posCreate.lineNumber),
posCreate
)?.syntax;
const syntaxesAction = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, posAction.lineNumber),
posAction
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN
);
const suggestionCreate = syntaxesCreate?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN_CREATE
);
const suggestionAction = syntaxesAction?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN
);
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['column_name']);
expect(suggestionCreate).not.toBeUndefined();
expect(suggestionCreate?.wordRanges.map((token) => token.text)).toEqual([
'new_column_name',
]);
expect(suggestionAction).not.toBeUndefined();
expect(suggestionAction?.wordRanges.map((token) => token.text)).toEqual(['column_name']);
});
test('Alter PUBLICATION With Column', () => {
const pos: CaretPosition = {
lineNumber: 37,
column: 58,
};
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN
);
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['column_name']);
});
test('Alter SEQUENCE With Column', () => {
const pos: CaretPosition = {
lineNumber: 39,
column: 52,
};
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN
);
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['column_name']);
});
test('Alter Table With Column', () => {
const pos: CaretPosition = {
lineNumber: 7,
column: 33,
};
const posCreate: CaretPosition = {
lineNumber: 41,
column: 34,
};
const posAction: CaretPosition = {
lineNumber: 41,
column: 53,
};
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const syntaxesCreate = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, posCreate.lineNumber),
posCreate
)?.syntax;
const syntaxesAction = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, posAction.lineNumber),
posAction
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN
);
const suggestionCreate = syntaxesCreate?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN
);
const suggestionAction = syntaxesAction?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN_CREATE
);
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['column_name']);
expect(suggestionCreate).not.toBeUndefined();
expect(suggestionCreate?.wordRanges.map((token) => token.text)).toEqual(['column_name']);
expect(suggestionAction).not.toBeUndefined();
expect(suggestionAction?.wordRanges.map((token) => token.text)).toEqual([
'new_column_name',
]);
});
test('ANALYZE With Column', () => {
const pos: CaretPosition = {
lineNumber: 43,
column: 32,
};
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN
);
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['column_name']);
});
test('Comment On With Column', () => {
const pos: CaretPosition = {
lineNumber: 45,
column: 44,
};
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN
);
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['column_name']);
});
test('Copy With Column', () => {
const pos: CaretPosition = {
lineNumber: 47,
column: 26,
};
const pos1: CaretPosition = {
lineNumber: 47,
column: 37,
};
const pos2: CaretPosition = {
lineNumber: 47,
column: 84,
};
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const syntaxes1 = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos1.lineNumber),
pos1
)?.syntax;
const syntaxes2 = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos2.lineNumber),
pos2
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN
);
const suggestion1 = syntaxes1?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN
);
const suggestion2 = syntaxes2?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN
);
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['col_name']);
expect(suggestion1).not.toBeUndefined();
expect(suggestion1?.wordRanges.map((token) => token.text)).toEqual(['col_name2']);
expect(suggestion2).not.toBeUndefined();
expect(suggestion2?.wordRanges.map((token) => token.text)).toEqual(['clumn_name']);
});
test('Create Foreign Table With Column', () => {
const pos: CaretPosition = {
lineNumber: 49,
column: 45,
};
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN
);
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['column_name']);
});
test('Create Function With Column', () => {
const pos: CaretPosition = {
lineNumber: 51,
column: 54,
};
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN
);
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['column_name']);
});
test('Create Index With Column', () => {
const pos: CaretPosition = {
lineNumber: 53,
column: 40,
};
const pos1: CaretPosition = {
lineNumber: 53,
column: 60,
};
const pos2: CaretPosition = {
lineNumber: 53,
column: 71,
};
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const syntaxes1 = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos1.lineNumber),
pos1
)?.syntax;
const syntaxes2 = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos2.lineNumber),
pos2
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN
);
const suggestion1 = syntaxes1?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN
);
const suggestion2 = syntaxes2?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN
);
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['column_name']);
expect(suggestion1).not.toBeUndefined();
expect(suggestion1?.wordRanges.map((token) => token.text)).toEqual(['col_name1']);
expect(suggestion2).not.toBeUndefined();
expect(suggestion2?.wordRanges.map((token) => token.text)).toEqual(['col_name2']);
});
test('Create MATERIALIZED VIEW With Column', () => {
const pos: CaretPosition = {
lineNumber: 55,
column: 46,
};
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN
);
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['col_name']);
});
test('Create STATISTICS With Column', () => {
const pos: CaretPosition = {
lineNumber: 57,
column: 33,
};
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN
);
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['column_name']);
});
test('Create TRIGGER With Column', () => {
const pos: CaretPosition = {
lineNumber: 59,
column: 48,
};
const pos1: CaretPosition = {
lineNumber: 59,
column: 93,
};
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const syntaxes1 = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos1.lineNumber),
pos1
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN
);
const suggestion1 = syntaxes1?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.FUNCTION
);
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['column_name']);
expect(suggestion1).not.toBeUndefined();
expect(suggestion1?.wordRanges.map((token) => token.text)).toEqual(['function_name']);
});
test('GRANT With Column', () => {
const pos: CaretPosition = {
lineNumber: 61,
column: 27,
};
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN
);
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['column_name']);
});
test('Insert Into With Column', () => {
const pos: CaretPosition = {
lineNumber: 63,
column: 36,
};
const pos1: CaretPosition = {
lineNumber: 63,
column: 83,
};
const pos2: CaretPosition = {
lineNumber: 63,
column: 114,
};
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const syntaxes1 = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos1.lineNumber),
pos1
)?.syntax;
const syntaxes2 = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos2.lineNumber),
pos2
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN
);
const suggestion1 = syntaxes1?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN
);
const suggestion2 = syntaxes2?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN
);
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['column_name']);
expect(suggestion1).not.toBeUndefined();
expect(suggestion1?.wordRanges.map((token) => token.text)).toEqual(['index_column_name']);
expect(suggestion2).not.toBeUndefined();
expect(suggestion2?.wordRanges.map((token) => token.text)).toEqual(['column_name_exp']);
});
test('Merge With Column', () => {
const pos: CaretPosition = {
lineNumber: 65,
column: 132,
};
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN
);
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['col_name']);
});
test('REVOKE With Column', () => {
const pos: CaretPosition = {
lineNumber: 67,
column: 23,
};
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN
);
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['co_name']);
});
test('SECURITY With Column', () => {
const pos: CaretPosition = {
lineNumber: 69,
column: 46,
};
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN
);
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['columnname']);
});
test('Select With Column', () => {
const pos: CaretPosition = {
lineNumber: 71,
column: 31,
};
const pos1: CaretPosition = {
lineNumber: 71,
column: 103,
};
const pos2: CaretPosition = {
lineNumber: 71,
column: 119,
};
const pos3: CaretPosition = {
lineNumber: 71,
column: 134,
};
const pos4: CaretPosition = {
lineNumber: 71,
column: 147,
};
const pos5: CaretPosition = {
lineNumber: 71,
column: 162,
};
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const syntaxes1 = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos1.lineNumber),
pos1
)?.syntax;
const syntaxes2 = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos2.lineNumber),
pos2
)?.syntax;
const syntaxes3 = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos3.lineNumber),
pos3
)?.syntax;
const syntaxes4 = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos4.lineNumber),
pos4
)?.syntax;
const syntaxes5 = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos5.lineNumber),
pos5
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN
);
const suggestion1 = syntaxes1?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN
);
const suggestion2 = syntaxes2?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN
);
const suggestion3 = syntaxes3?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN
);
const suggestion4 = syntaxes4?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN
);
const suggestion5 = syntaxes5?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN
);
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['col_name']);
expect(suggestion1).not.toBeUndefined();
expect(suggestion1?.wordRanges.map((token) => token.text)).toEqual(['column_name']);
expect(suggestion2).not.toBeUndefined();
expect(suggestion2?.wordRanges.map((token) => token.text)).toEqual(['column_name']);
expect(suggestion3).not.toBeUndefined();
expect(suggestion3?.wordRanges.map((token) => token.text)).toEqual(['col_name']);
expect(suggestion4).not.toBeUndefined();
expect(suggestion4?.wordRanges.map((token) => token.text)).toEqual(['col_name']);
expect(suggestion5).not.toBeUndefined();
expect(suggestion5?.wordRanges.map((token) => token.text)).toEqual(['col_name']);
});
test('Update With Column', () => {
const pos: CaretPosition = {
lineNumber: 73,
column: 32,
};
const pos1: CaretPosition = {
lineNumber: 73,
column: 47,
};
const pos2: CaretPosition = {
lineNumber: 73,
column: 53,
};
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const syntaxes1 = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos1.lineNumber),
pos1
)?.syntax;
const syntaxes2 = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos2.lineNumber),
pos2
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN
);
const suggestion1 = syntaxes1?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN
);
const suggestion2 = syntaxes2?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN
);
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['columnname']);
expect(suggestion1).not.toBeUndefined();
expect(suggestion1?.wordRanges.map((token) => token.text)).toEqual(['col1']);
expect(suggestion2).not.toBeUndefined();
expect(suggestion2?.wordRanges.map((token) => token.text)).toEqual(['col2']);
});
test('Vacuum With Column', () => {
const pos: CaretPosition = {
lineNumber: 75,
column: 23,
};
const pos1: CaretPosition = {
lineNumber: 75,
column: 29,
};
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const syntaxes1 = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos1.lineNumber),
pos1
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN
);
const suggestion1 = syntaxes1?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN
);
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['col1']);
expect(suggestion1).not.toBeUndefined();
expect(suggestion1?.wordRanges.map((token) => token.text)).toEqual(['col2']);
});
test('Select table with expression', () => {
const pos1: CaretPosition = {
lineNumber: 77,
column: 36,
};
const pos2: CaretPosition = {
lineNumber: 77,
column: 42,
};
const pos3: CaretPosition = {
lineNumber: 77,
column: 57,
};
const syntaxes1 = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos1.lineNumber),
pos1
)?.syntax;
const syntaxes2 = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos2.lineNumber),
pos2
)?.syntax;
const syntaxes3 = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos3.lineNumber),
pos3
)?.syntax;
const suggestion1 = syntaxes1?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN
);
const suggestion2 = syntaxes2?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN
);
const suggestion3 = syntaxes3?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.COLUMN
);
expect(suggestion1).not.toBeUndefined();
expect(suggestion1?.wordRanges.map((token) => token.text)).toEqual(['col1']);
expect(suggestion2).not.toBeUndefined();
expect(suggestion2?.wordRanges.map((token) => token.text)).toEqual(['col2']);
expect(suggestion3).not.toBeUndefined();
expect(suggestion3?.wordRanges.map((token) => token.text)).toEqual(['col3']);
});
});

View File

@ -181,7 +181,9 @@ MOVE NEXT FROM cursor_name;
WITH query_name (id) AS (SELECT id FROM table_expression)
MERGE INTO ONLY target_table_name * AS target_alias
USING ONLY source_table_name * ON s.winename = w.winename
WHEN MATCHED AND s.winename = w.winename THEN UPDATE SET column_name = DEFAULT;
WHEN MATCHED AND s.winename = w.winename THEN UPDATE SET column_name = stock + 3
WHEN NOT MATCHED AND stock_delta + stock > 0 THEN INSERT ( column_name) OVERRIDING SYSTEM VALUE VALUES (s.winename)
WHEN MATCHED THEN DELETE;
-- NOTIFY
NOTIFY virtual, 'This is the payload';

View File

@ -13,6 +13,8 @@ WINDOW w AS (PARTITION BY depname ORDER BY salary DESC)
FOR UPDATE OF table_name, table_name2 NOWAIT;
SELECT;
SELECT * FROM db.tbs GROUP BY (col1 > 3, col2 < 8) ORDER BY col3 > 9;
WITH query_name (id) AS (SELECT id FROM table_expression) SELECT DISTINCT random() AS name1 FROM table_expression WHERE name1=name1 GROUP BY id HAVING sum(len) < interval '5 hours' WINDOW w AS (PARTITION BY depname ORDER BY salary DESC) INTERSECT DISTINCT (SELECT * FROM others) ORDER BY salary ASC LIMIT ALL OFFSET start FETCH NEXT ROW ONLY FOR NO KEY UPDATE;
WITH query_name (id) AS (SELECT id FROM table_expression) SELECT DISTINCT ON (col1) random() AS name1 FROM table_expression WHERE name1=name1 GROUP BY id HAVING sum(len) < interval '5 hours' WINDOW w AS (PARTITION BY depname ORDER BY salary DESC) EXCEPT (SELECT * FROM others) ORDER BY salary USING > NULL FIRST LIMIT 40 OFFSET start FETCH NEXT ROW ONLY FOR SHARE;