pgsql-ast-parser
Advanced tools
Comparing version 10.0.5 to 10.1.0
@@ -14,8 +14,6 @@ import * as a from './syntax/ast'; | ||
createSchema?: (val: a.CreateSchemaStatement) => a.Statement | nil; | ||
dropTable?: (val: a.DropTableStatement) => a.Statement | nil; | ||
createEnum?(val: a.CreateEnumType): a.Statement | nil; | ||
createCompositeType?(val: a.CreateCompositeType): a.Statement | nil; | ||
dropIndex?: (val: a.DropIndexStatement) => a.Statement | nil; | ||
drop?: (val: a.DropStatement) => a.Statement | nil; | ||
show?: (val: a.ShowStatement) => a.Statement | nil; | ||
dropSequence?: (val: a.DropSequenceStatement) => a.Statement | nil; | ||
createTable?: (val: a.CreateTableStatement) => a.Statement | nil; | ||
@@ -151,5 +149,3 @@ truncateTable?: (val: a.TruncateTableStatement) => a.Statement | nil; | ||
createCompositeType(val: a.CreateCompositeType): a.Statement | nil; | ||
dropTable(val: a.DropTableStatement): a.Statement | nil; | ||
dropIndex(val: a.DropIndexStatement): a.Statement | nil; | ||
dropSequence(val: a.DropSequenceStatement): a.Statement | nil; | ||
drop(val: a.DropStatement): a.Statement | nil; | ||
alterSequence(seq: a.AlterSequenceStatement): a.Statement | nil; | ||
@@ -156,0 +152,0 @@ begin(begin: a.BeginStatement): a.Statement | nil; |
{ | ||
"name": "pgsql-ast-parser", | ||
"version": "10.0.5", | ||
"version": "10.1.0", | ||
"description": "Yet another simple Postgres SQL parser/modifier", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -17,8 +17,6 @@ import * as a from './syntax/ast'; | ||
createSchema?: (val: a.CreateSchemaStatement) => a.Statement | nil | ||
dropTable?: (val: a.DropTableStatement) => a.Statement | nil | ||
createEnum?(val: a.CreateEnumType): a.Statement | nil | ||
createCompositeType?(val: a.CreateCompositeType): a.Statement | nil | ||
dropIndex?: (val: a.DropIndexStatement) => a.Statement | nil | ||
drop?: (val: a.DropStatement) => a.Statement | nil | ||
show?: (val: a.ShowStatement) => a.Statement | nil | ||
dropSequence?: (val: a.DropSequenceStatement) => a.Statement | nil | ||
createTable?: (val: a.CreateTableStatement) => a.Statement | nil | ||
@@ -257,8 +255,7 @@ truncateTable?: (val: a.TruncateTableStatement) => a.Statement | nil | ||
return this.begin(val); | ||
case 'drop table': | ||
case 'drop index': | ||
return this.dropIndex(val); | ||
case 'drop sequence': | ||
return this.dropSequence(val); | ||
case 'drop table': | ||
return this.dropTable(val); | ||
case 'drop type': | ||
return this.drop(val); | ||
case 'create enum': | ||
@@ -400,11 +397,6 @@ return this.createEnum(val); | ||
dropTable(val: a.DropTableStatement): a.Statement | nil { | ||
drop(val: a.DropStatement): a.Statement | nil { | ||
return val; | ||
} | ||
dropIndex(val: a.DropIndexStatement): a.Statement | nil { | ||
return val; | ||
} | ||
dropSequence(val: a.DropSequenceStatement): a.Statement | nil { | ||
return val; | ||
} | ||
@@ -411,0 +403,0 @@ alterSequence(seq: a.AlterSequenceStatement): a.Statement | nil { |
@@ -36,5 +36,3 @@ // import { IType } from '../../interfaces'; | ||
| TruncateTableStatement | ||
| DropTableStatement | ||
| DropSequenceStatement | ||
| DropIndexStatement | ||
| DropStatement | ||
| CommentStatement | ||
@@ -195,19 +193,8 @@ | CreateSchemaStatement | ||
} | ||
export interface DropTableStatement extends PGNode { | ||
type: 'drop table'; | ||
name: QName; | ||
export interface DropStatement extends PGNode { | ||
type: 'drop table' | 'drop sequence' | 'drop index' | 'drop type'; | ||
names: QName[]; | ||
ifExists?: boolean; | ||
cascade?: 'cascade' | 'restrict'; | ||
} | ||
export interface DropSequenceStatement extends PGNode { | ||
type: 'drop sequence'; | ||
name: QName; | ||
ifExists?: boolean; | ||
} | ||
export interface DropIndexStatement extends PGNode { | ||
type: 'drop index'; | ||
name: QName; | ||
ifExists?: boolean; | ||
concurrently?: boolean; | ||
@@ -214,0 +201,0 @@ } |
@@ -9,3 +9,3 @@ import 'mocha'; | ||
type: 'drop table', | ||
name: { name: 'test' }, | ||
names: [{ name: 'test' }], | ||
}); | ||
@@ -15,3 +15,3 @@ | ||
type: 'drop table', | ||
name: { name: 'test' }, | ||
names: [{ name: 'test' }], | ||
ifExists: true, | ||
@@ -22,3 +22,3 @@ }); | ||
type: 'drop table', | ||
name: { name: 'Users' }, | ||
names: [{ name: 'Users' }], | ||
ifExists: true, | ||
@@ -28,5 +28,21 @@ cascade: 'cascade', | ||
checkStatement([`DROP TABLE IF EXISTS a, b CASCADE`], { | ||
type: 'drop table', | ||
names: [{ name: 'a' }, { name: 'b' }], | ||
ifExists: true, | ||
cascade: 'cascade', | ||
}); | ||
checkStatement([`DROP TYPE IF EXISTS a, b CASCADE`], { | ||
type: 'drop type', | ||
names: [{ name: 'a' }, { name: 'b' }], | ||
ifExists: true, | ||
cascade: 'cascade', | ||
}); | ||
checkStatement([`DROP TABLE IF EXISTS "Users" RESTRICT`], { | ||
type: 'drop table', | ||
name: { name: 'Users' }, | ||
names: [{ name: 'Users' }], | ||
ifExists: true, | ||
@@ -39,3 +55,3 @@ cascade: 'restrict', | ||
type: 'drop index', | ||
name: { name: 'test' }, | ||
names: [{ name: 'test' }], | ||
}); | ||
@@ -45,3 +61,3 @@ | ||
type: 'drop index', | ||
name: { name: 'test', schema: 'pub' }, | ||
names: [{ name: 'test', schema: 'pub' }], | ||
}); | ||
@@ -52,3 +68,3 @@ | ||
type: 'drop sequence', | ||
name: { name: 'test' }, | ||
names: [{ name: 'test' }], | ||
}); | ||
@@ -58,3 +74,3 @@ | ||
type: 'drop index', | ||
name: { name: 'test' }, | ||
names: [{ name: 'test' }], | ||
concurrently: true, | ||
@@ -61,0 +77,0 @@ ifExists: true, |
@@ -622,14 +622,4 @@ import { IAstPartialMapper, AstDefaultMapper } from './ast-mapper'; | ||
dropTable: val => { | ||
ret.push('DROP TABLE '); | ||
if (val.ifExists) { | ||
ret.push('IF EXISTS '); | ||
} | ||
m.tableRef(val.name); | ||
if (val.cascade) { | ||
ret.push(' ', val.cascade, ' '); | ||
} | ||
}, | ||
dropIndex: val => { | ||
ret.push('DROP INDEX '); | ||
drop: val => { | ||
ret.push(val.type.toUpperCase(), ' '); | ||
if (val.concurrently) { | ||
@@ -641,10 +631,6 @@ ret.push('CONCURRENTLY '); | ||
} | ||
m.tableRef(val.name); | ||
}, | ||
dropSequence: val => { | ||
ret.push('DROP SEQUENCE '); | ||
if (val.ifExists) { | ||
ret.push('IF EXISTS '); | ||
list(val.names, x => m.tableRef(x), false); | ||
if (val.cascade) { | ||
ret.push(val.cascade.toUpperCase(), ' '); | ||
} | ||
m.tableRef(val.name); | ||
}, | ||
@@ -651,0 +637,0 @@ |
import { nil } from '../utils'; | ||
export declare function locationOf(node: PGNode): NodeLocation; | ||
export declare type Statement = SelectStatement | CreateTableStatement | CreateSequenceStatement | CreateIndexStatement | CreateExtensionStatement | CommitStatement | InsertStatement | UpdateStatement | ShowStatement | PrepareStatement | DeallocateStatement | DeleteStatement | WithStatement | RollbackStatement | TablespaceStatement | CreateViewStatement | CreateMaterializedViewStatement | AlterTableStatement | AlterSequenceStatement | SetGlobalStatement | SetTimezone | CreateEnumType | CreateCompositeType | TruncateTableStatement | DropTableStatement | DropSequenceStatement | DropIndexStatement | CommentStatement | CreateSchemaStatement | WithRecursiveStatement | RaiseStatement | ValuesStatement | CreateFunctionStatement | DropFunctionStatement | DoStatement | BeginStatement | StartTransactionStatement; | ||
export declare type Statement = SelectStatement | CreateTableStatement | CreateSequenceStatement | CreateIndexStatement | CreateExtensionStatement | CommitStatement | InsertStatement | UpdateStatement | ShowStatement | PrepareStatement | DeallocateStatement | DeleteStatement | WithStatement | RollbackStatement | TablespaceStatement | CreateViewStatement | CreateMaterializedViewStatement | AlterTableStatement | AlterSequenceStatement | SetGlobalStatement | SetTimezone | CreateEnumType | CreateCompositeType | TruncateTableStatement | DropStatement | CommentStatement | CreateSchemaStatement | WithRecursiveStatement | RaiseStatement | ValuesStatement | CreateFunctionStatement | DropFunctionStatement | DoStatement | BeginStatement | StartTransactionStatement; | ||
export interface PGNode { | ||
@@ -125,17 +125,7 @@ _location?: NodeLocation; | ||
} | ||
export interface DropTableStatement extends PGNode { | ||
type: 'drop table'; | ||
name: QName; | ||
export interface DropStatement extends PGNode { | ||
type: 'drop table' | 'drop sequence' | 'drop index' | 'drop type'; | ||
names: QName[]; | ||
ifExists?: boolean; | ||
cascade?: 'cascade' | 'restrict'; | ||
} | ||
export interface DropSequenceStatement extends PGNode { | ||
type: 'drop sequence'; | ||
name: QName; | ||
ifExists?: boolean; | ||
} | ||
export interface DropIndexStatement extends PGNode { | ||
type: 'drop index'; | ||
name: QName; | ||
ifExists?: boolean; | ||
concurrently?: boolean; | ||
@@ -142,0 +132,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1593833
17243