Co-authored-by: zhaoge <>
This commit is contained in:
parent
ecbbee32c7
commit
337885be8b
@ -3258,7 +3258,7 @@ from_list
|
|||||||
|
|
||||||
table_ref
|
table_ref
|
||||||
: (
|
: (
|
||||||
relation_expr opt_alias_clause? tablesample_clause?
|
(relation_expr | view_relation_expr) opt_alias_clause? tablesample_clause?
|
||||||
| func_table func_alias_clause?
|
| func_table func_alias_clause?
|
||||||
| xmltable opt_alias_clause?
|
| xmltable opt_alias_clause?
|
||||||
| select_with_parens opt_alias_clause?
|
| select_with_parens opt_alias_clause?
|
||||||
@ -3307,6 +3307,10 @@ relation_expr
|
|||||||
| KW_IN KW_SCHEMA (schema_name | KW_CURRENT_SCHEMA)
|
| KW_IN KW_SCHEMA (schema_name | KW_CURRENT_SCHEMA)
|
||||||
;
|
;
|
||||||
|
|
||||||
|
view_relation_expr
|
||||||
|
: KW_ONLY? view_name STAR? columnlist? where_clause?
|
||||||
|
;
|
||||||
|
|
||||||
publication_relation_expr
|
publication_relation_expr
|
||||||
: KW_TABLE KW_ONLY? table_name STAR? (OPEN_PAREN columnlist CLOSE_PAREN)? where_clause?
|
: KW_TABLE KW_ONLY? table_name STAR? (OPEN_PAREN columnlist CLOSE_PAREN)? where_clause?
|
||||||
| KW_TABLE KW_ONLY ( table_name | OPEN_PAREN table_name CLOSE_PAREN)
|
| KW_TABLE KW_ONLY ( table_name | OPEN_PAREN table_name CLOSE_PAREN)
|
||||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -574,6 +574,7 @@ import { Func_alias_clauseContext } from "./PostgreSQLParser";
|
|||||||
import { Join_typeContext } from "./PostgreSQLParser";
|
import { Join_typeContext } from "./PostgreSQLParser";
|
||||||
import { Join_qualContext } from "./PostgreSQLParser";
|
import { Join_qualContext } from "./PostgreSQLParser";
|
||||||
import { Relation_exprContext } from "./PostgreSQLParser";
|
import { Relation_exprContext } from "./PostgreSQLParser";
|
||||||
|
import { View_relation_exprContext } from "./PostgreSQLParser";
|
||||||
import { Publication_relation_exprContext } from "./PostgreSQLParser";
|
import { Publication_relation_exprContext } from "./PostgreSQLParser";
|
||||||
import { Relation_expr_listContext } from "./PostgreSQLParser";
|
import { Relation_expr_listContext } from "./PostgreSQLParser";
|
||||||
import { Publication_relation_expr_listContext } from "./PostgreSQLParser";
|
import { Publication_relation_expr_listContext } from "./PostgreSQLParser";
|
||||||
@ -7196,6 +7197,17 @@ export interface PostgreSQLParserListener extends ParseTreeListener {
|
|||||||
*/
|
*/
|
||||||
exitRelation_expr?: (ctx: Relation_exprContext) => void;
|
exitRelation_expr?: (ctx: Relation_exprContext) => void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enter a parse tree produced by `PostgreSQLParser.view_relation_expr`.
|
||||||
|
* @param ctx the parse tree
|
||||||
|
*/
|
||||||
|
enterView_relation_expr?: (ctx: View_relation_exprContext) => void;
|
||||||
|
/**
|
||||||
|
* Exit a parse tree produced by `PostgreSQLParser.view_relation_expr`.
|
||||||
|
* @param ctx the parse tree
|
||||||
|
*/
|
||||||
|
exitView_relation_expr?: (ctx: View_relation_exprContext) => void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter a parse tree produced by `PostgreSQLParser.publication_relation_expr`.
|
* Enter a parse tree produced by `PostgreSQLParser.publication_relation_expr`.
|
||||||
* @param ctx the parse tree
|
* @param ctx the parse tree
|
||||||
|
@ -574,6 +574,7 @@ import { Func_alias_clauseContext } from "./PostgreSQLParser";
|
|||||||
import { Join_typeContext } from "./PostgreSQLParser";
|
import { Join_typeContext } from "./PostgreSQLParser";
|
||||||
import { Join_qualContext } from "./PostgreSQLParser";
|
import { Join_qualContext } from "./PostgreSQLParser";
|
||||||
import { Relation_exprContext } from "./PostgreSQLParser";
|
import { Relation_exprContext } from "./PostgreSQLParser";
|
||||||
|
import { View_relation_exprContext } from "./PostgreSQLParser";
|
||||||
import { Publication_relation_exprContext } from "./PostgreSQLParser";
|
import { Publication_relation_exprContext } from "./PostgreSQLParser";
|
||||||
import { Relation_expr_listContext } from "./PostgreSQLParser";
|
import { Relation_expr_listContext } from "./PostgreSQLParser";
|
||||||
import { Publication_relation_expr_listContext } from "./PostgreSQLParser";
|
import { Publication_relation_expr_listContext } from "./PostgreSQLParser";
|
||||||
@ -4905,6 +4906,13 @@ export interface PostgreSQLParserVisitor<Result> extends ParseTreeVisitor<Result
|
|||||||
*/
|
*/
|
||||||
visitRelation_expr?: (ctx: Relation_exprContext) => Result;
|
visitRelation_expr?: (ctx: Relation_exprContext) => Result;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Visit a parse tree produced by `PostgreSQLParser.view_relation_expr`.
|
||||||
|
* @param ctx the parse tree
|
||||||
|
* @return the visitor result
|
||||||
|
*/
|
||||||
|
visitView_relation_expr?: (ctx: View_relation_exprContext) => Result;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Visit a parse tree produced by `PostgreSQLParser.publication_relation_expr`.
|
* Visit a parse tree produced by `PostgreSQLParser.publication_relation_expr`.
|
||||||
* @param ctx the parse tree
|
* @param ctx the parse tree
|
||||||
|
@ -25,7 +25,7 @@ describe('PgSQL Multiple Statements Syntax Suggestion', () => {
|
|||||||
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual([]);
|
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual([]);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Select from table', () => {
|
test('Select from table or view', () => {
|
||||||
const pos: CaretPosition = {
|
const pos: CaretPosition = {
|
||||||
lineNumber: 9,
|
lineNumber: 9,
|
||||||
column: 18,
|
column: 18,
|
||||||
@ -34,9 +34,14 @@ describe('PgSQL Multiple Statements Syntax Suggestion', () => {
|
|||||||
const suggestion = syntaxes?.find(
|
const suggestion = syntaxes?.find(
|
||||||
(syn) => syn.syntaxContextType === SyntaxContextType.TABLE
|
(syn) => syn.syntaxContextType === SyntaxContextType.TABLE
|
||||||
);
|
);
|
||||||
|
const suggestionVw = syntaxes?.find(
|
||||||
|
(syn) => syn.syntaxContextType === SyntaxContextType.VIEW
|
||||||
|
);
|
||||||
|
|
||||||
expect(suggestion).not.toBeUndefined();
|
expect(suggestion).not.toBeUndefined();
|
||||||
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['db', '.']);
|
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['db', '.']);
|
||||||
|
expect(suggestionVw).not.toBeUndefined();
|
||||||
|
expect(suggestionVw?.wordRanges.map((token) => token.text)).toEqual(['db', '.']);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Insert into table ', () => {
|
test('Insert into table ', () => {
|
||||||
|
Loading…
Reference in New Issue
Block a user