pgsql-ast-parser
Advanced tools
Comparing version 1.3.5 to 1.3.6
@@ -12,2 +12,3 @@ import * as a from './syntax/ast'; | ||
createTable?: (val: a.CreateTableStatement) => a.Statement | nil; | ||
truncateTable?: (val: a.TruncateTableStatement) => a.Statement | nil; | ||
createExtension?: (val: a.CreateExtensionStatement) => a.Statement | nil; | ||
@@ -117,2 +118,3 @@ set?: (st: a.SetStatement) => a.SetStatement | nil; | ||
createTable(val: a.CreateTableStatement): a.Statement | nil; | ||
truncateTable(val: a.TruncateTableStatement): a.Statement | nil; | ||
constraint(c: a.ColumnConstraint): a.ColumnConstraint | nil; | ||
@@ -119,0 +121,0 @@ set(st: a.SetStatement): a.SetStatement | nil; |
{ | ||
"name": "pgsql-ast-parser", | ||
"version": "1.3.5", | ||
"version": "1.3.6", | ||
"description": "Yet another simple Postgres SQL parser/modifier", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -15,2 +15,3 @@ import * as a from './syntax/ast'; | ||
createTable?: (val: a.CreateTableStatement) => a.Statement | nil | ||
truncateTable?: (val: a.TruncateTableStatement) => a.Statement | nil | ||
createExtension?: (val: a.CreateExtensionStatement) => a.Statement | nil | ||
@@ -176,2 +177,4 @@ set?: (st: a.SetStatement) => a.SetStatement | nil | ||
return this.createTable(val); | ||
case 'truncate table': | ||
return this.truncateTable(val); | ||
case 'delete': | ||
@@ -350,2 +353,7 @@ return this.delete(val); | ||
truncateTable(val: a.TruncateTableStatement): a.Statement | nil { | ||
return val; | ||
} | ||
constraint(c: a.ColumnConstraint): a.ColumnConstraint | nil { | ||
@@ -352,0 +360,0 @@ switch (c.type) { |
@@ -20,2 +20,3 @@ // import { IType } from '../../interfaces'; | ||
| SetGlobalStatement | ||
| TruncateTableStatement | ||
| DropTableStatement | ||
@@ -28,2 +29,5 @@ | DropSequenceStatement | ||
export interface TruncateTableStatement extends QName { | ||
type: 'truncate table'; | ||
} | ||
export interface DropTableStatement extends QName { | ||
@@ -30,0 +34,0 @@ type: 'drop table'; |
import 'mocha'; | ||
import 'chai'; | ||
import { checkDelete } from './spec-utils'; | ||
import { checkDelete, checkStatement } from './spec-utils'; | ||
@@ -19,3 +19,8 @@ describe('Delete', () => { | ||
checkDelete([`truncate test`, `truncate table test`], { | ||
checkStatement([`truncate test`, `truncate table test`], { | ||
type: 'truncate table', | ||
name: 'test', | ||
}); | ||
checkDelete([`delete from test`], { | ||
type: 'delete', | ||
@@ -22,0 +27,0 @@ from: { name: 'test' }, |
@@ -506,6 +506,4 @@ import { IAstPartialMapper, AstDefaultMapper } from './ast-mapper'; | ||
ret.push(t.ifNotExists ? 'CREATE TABLE IF NOT EXISTS ' : 'CREATE TABLE '); | ||
if (t.schema) { | ||
ret.push(name(t.schema), '.'); | ||
} | ||
ret.push(name(t.name), '('); | ||
m.tableRef(t); | ||
ret.push('('); | ||
list(t.columns, c => m.createColumn(c), false); | ||
@@ -525,2 +523,7 @@ if (t.constraints) { | ||
truncateTable: t => { | ||
ret.push('TRUNCATE TABLE '); | ||
m.tableRef(t); | ||
}, | ||
delete: t => { | ||
@@ -527,0 +530,0 @@ ret.push('DELETE FROM '); |
import { nil } from '../utils'; | ||
export declare const LOCATION: unique symbol; | ||
export declare type Statement = (SelectStatement | CreateTableStatement | CreateSequenceStatement | CreateIndexStatement | CreateExtensionStatement | CommitStatement | InsertStatement | UpdateStatement | DeleteStatement | RollbackStatement | TablespaceStatement | AlterTableStatement | AlterSequenceStatement | SetGlobalStatement | DropTableStatement | DropSequenceStatement | DropIndexStatement | StartTransactionStatement) & { | ||
export declare type Statement = (SelectStatement | CreateTableStatement | CreateSequenceStatement | CreateIndexStatement | CreateExtensionStatement | CommitStatement | InsertStatement | UpdateStatement | DeleteStatement | RollbackStatement | TablespaceStatement | AlterTableStatement | AlterSequenceStatement | SetGlobalStatement | TruncateTableStatement | DropTableStatement | DropSequenceStatement | DropIndexStatement | StartTransactionStatement) & { | ||
[LOCATION]?: StatementLocation; | ||
}; | ||
export interface TruncateTableStatement extends QName { | ||
type: 'truncate table'; | ||
} | ||
export interface DropTableStatement extends QName { | ||
@@ -7,0 +10,0 @@ type: 'drop table'; |
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
813657
8992