pgsql-ast-parser
Advanced tools
Comparing version 9.2.1 to 9.2.2
@@ -33,2 +33,3 @@ import * as a from './syntax/ast'; | ||
dropColumn?: (change: a.TableAlterationDropColumn, table: a.QNameAliased) => a.TableAlteration | nil; | ||
dropConstraint?: (change: a.TableAlterationDropConstraint, table: a.QNameAliased) => a.TableAlteration | nil; | ||
renameConstraint?: (change: a.TableAlterationRenameConstraint, table: a.QNameAliased) => a.TableAlteration | nil; | ||
@@ -178,2 +179,3 @@ setTableOwner?: (change: a.TableAlterationOwner, table: a.QNameAliased) => a.TableAlteration | nil; | ||
dropColumn(change: a.TableAlterationDropColumn, table: a.QNameAliased): a.TableAlteration | nil; | ||
dropConstraint(change: a.TableAlterationDropConstraint, table: a.QNameAliased): a.TableAlteration | nil; | ||
setTableOwner(change: a.TableAlterationOwner, table: a.QNameAliased): a.TableAlteration | nil; | ||
@@ -180,0 +182,0 @@ renameConstraint(change: a.TableAlterationRenameConstraint, table: a.QNameAliased): a.TableAlteration | nil; |
{ | ||
"name": "pgsql-ast-parser", | ||
"version": "9.2.1", | ||
"version": "9.2.2", | ||
"description": "Yet another simple Postgres SQL parser/modifier", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -36,2 +36,3 @@ import * as a from './syntax/ast'; | ||
dropColumn?: (change: a.TableAlterationDropColumn, table: a.QNameAliased) => a.TableAlteration | nil | ||
dropConstraint?: (change: a.TableAlterationDropConstraint, table: a.QNameAliased) => a.TableAlteration | nil | ||
renameConstraint?: (change: a.TableAlterationRenameConstraint, table: a.QNameAliased) => a.TableAlteration | nil | ||
@@ -713,2 +714,4 @@ setTableOwner?: (change: a.TableAlterationOwner, table: a.QNameAliased) => a.TableAlteration | nil | ||
return this.dropColumn(change, table); | ||
case 'drop constraint': | ||
return this.dropConstraint(change, table); | ||
case 'owner': | ||
@@ -725,2 +728,6 @@ return this.setTableOwner(change, table); | ||
dropConstraint(change: a.TableAlterationDropConstraint, table: a.QNameAliased): a.TableAlteration | nil { | ||
return change; | ||
} | ||
setTableOwner(change: a.TableAlterationOwner, table: a.QNameAliased): a.TableAlteration | nil { | ||
@@ -727,0 +734,0 @@ return change; |
@@ -105,2 +105,37 @@ import 'mocha'; | ||
checkAlterTable(['alter table test drop constraint if exists a'], { | ||
type: 'alter table', | ||
table: { name: 'test' }, | ||
changes: [{ | ||
type: 'drop constraint', | ||
constraint: { name: 'a' }, | ||
ifExists: true, | ||
}] | ||
}); | ||
checkAlterTable(['alter table test drop constraint a cascade'], { | ||
type: 'alter table', | ||
table: { name: 'test' }, | ||
changes: [{ | ||
type: 'drop constraint', | ||
constraint: { name: 'a' }, | ||
behaviour: 'cascade', | ||
}] | ||
}); | ||
checkAlterTable(['alter table test drop constraint a restrict'], { | ||
type: 'alter table', | ||
table: { name: 'test' }, | ||
changes: [{ | ||
type: 'drop constraint', | ||
constraint: { name: 'a' }, | ||
behaviour: 'restrict', | ||
}] | ||
}); | ||
checkAlterTable(['alter table test drop column a', 'alter table test drop a'], { | ||
@@ -107,0 +142,0 @@ type: 'alter table', |
@@ -286,2 +286,9 @@ // import { IType } from '../../interfaces'; | ||
export interface TableAlterationDropConstraint extends PGNode { | ||
type: 'drop constraint'; | ||
ifExists?: boolean; | ||
constraint: Name; | ||
behaviour?: 'cascade' | 'restrict'; | ||
} | ||
export interface TableAlterationAlterColumn extends PGNode { | ||
@@ -306,2 +313,3 @@ type: 'alter column', | ||
| TableAlterationOwner | ||
| TableAlterationDropConstraint | ||
@@ -308,0 +316,0 @@ |
@@ -373,2 +373,4 @@ import { IAstPartialMapper, AstDefaultMapper } from './ast-mapper'; | ||
return m.dropColumn(change, table); | ||
case 'drop constraint': | ||
return m.dropConstraint(change, table); | ||
case 'owner': | ||
@@ -1006,2 +1008,13 @@ return m.setTableOwner(change, table); | ||
dropConstraint: t => { | ||
ret.push(' DROP CONSTRAINT '); | ||
if (t.ifExists) { | ||
ret.push(' IF EXISTS '); | ||
} | ||
ret.push(name(t.constraint)); | ||
if (t.behaviour) { | ||
ret.push(' ', t.behaviour.toUpperCase(), ' '); | ||
} | ||
}, | ||
from: t => m.super().from(t), | ||
@@ -1008,0 +1021,0 @@ |
@@ -206,2 +206,8 @@ import { nil } from '../utils'; | ||
} | ||
export interface TableAlterationDropConstraint extends PGNode { | ||
type: 'drop constraint'; | ||
ifExists?: boolean; | ||
constraint: Name; | ||
behaviour?: 'cascade' | 'restrict'; | ||
} | ||
export interface TableAlterationAlterColumn extends PGNode { | ||
@@ -216,3 +222,3 @@ type: 'alter column'; | ||
} | ||
export declare type TableAlteration = TableAlterationRename | TableAlterationRenameColumn | TableAlterationRenameConstraint | TableAlterationAddColumn | TableAlterationDropColumn | TableAlterationAlterColumn | TableAlterationAddConstraint | TableAlterationOwner; | ||
export declare type TableAlteration = TableAlterationRename | TableAlterationRenameColumn | TableAlterationRenameConstraint | TableAlterationAddColumn | TableAlterationDropColumn | TableAlterationAlterColumn | TableAlterationAddConstraint | TableAlterationOwner | TableAlterationDropConstraint; | ||
export interface TableAlterationOwner extends PGNode { | ||
@@ -219,0 +225,0 @@ type: 'owner'; |
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
1513943
16692