feat: SQL 语法支持 CREATE TABLE IF NOT EXISTS
- Parser 支持 CREATE TABLE IF NOT EXISTS 语法 - AST CreateTableStatement 新增 ifNotExists 字段 - Executor 表已存在时静默跳过 - 修复 demo.html Aria 预设报错
This commit is contained in:
+11
-1
@@ -327,6 +327,16 @@ export class Parser {
|
||||
private parseCreateTable(): CreateTableStatement {
|
||||
this.expect(TokenType.CREATE);
|
||||
this.expect(TokenType.TABLE);
|
||||
|
||||
// IF NOT EXISTS(可选)
|
||||
let ifNotExists = false;
|
||||
if (this.curTokenIs(TokenType.IF)) {
|
||||
this.nextToken();
|
||||
this.expect(TokenType.NOT);
|
||||
this.expect(TokenType.EXISTS);
|
||||
ifNotExists = true;
|
||||
}
|
||||
|
||||
const tableName = this.expectIdentifier('table name');
|
||||
this.expect(TokenType.LPAREN);
|
||||
|
||||
@@ -338,7 +348,7 @@ export class Parser {
|
||||
|
||||
this.expect(TokenType.RPAREN);
|
||||
|
||||
return { type: 'CREATE_TABLE', name: tableName, columns };
|
||||
return { type: 'CREATE_TABLE', name: tableName, columns, ifNotExists: ifNotExists || undefined };
|
||||
}
|
||||
|
||||
private parseColumnDef(): ASTColumnDef {
|
||||
|
||||
Reference in New Issue
Block a user