New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

pgsql-ast-parser

Package Overview
Dependencies
Maintainers
1
Versions
108
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pgsql-ast-parser - npm Package Compare versions

Comparing version 9.1.2 to 9.2.0

2

ast-mapper.d.ts

@@ -11,2 +11,3 @@ import * as a from './syntax/ast';

createFunction?: (val: a.CreateFunctionStatement) => a.Statement | nil;
dropFunction?: (val: a.DropFunctionStatement) => a.Statement | nil;
raise?: (val: a.RaiseStatement) => a.Statement | nil;

@@ -143,2 +144,3 @@ createSchema?: (val: a.CreateSchemaStatement) => a.Statement | nil;

createFunction(val: a.CreateFunctionStatement): a.Statement | nil;
dropFunction(val: a.DropFunctionStatement): a.Statement | nil;
show(val: a.ShowStatement): a.Statement | nil;

@@ -145,0 +147,0 @@ createEnum(val: a.CreateEnumType): a.Statement | nil;

2

package.json
{
"name": "pgsql-ast-parser",
"version": "9.1.2",
"version": "9.2.0",
"description": "Yet another simple Postgres SQL parser/modifier",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -14,2 +14,3 @@ import * as a from './syntax/ast';

createFunction?: (val: a.CreateFunctionStatement) => a.Statement | nil
dropFunction?: (val: a.DropFunctionStatement) => a.Statement | nil
raise?: (val: a.RaiseStatement) => a.Statement | nil

@@ -284,2 +285,4 @@ createSchema?: (val: a.CreateSchemaStatement) => a.Statement | nil

return this.createFunction(val);
case 'drop function':
return this.dropFunction(val);
case 'values':

@@ -366,2 +369,13 @@ return this.values(val);

dropFunction(val: a.DropFunctionStatement): a.Statement | nil {
const args = arrayNilMap(val.arguments, a => {
const type = this.dataType(a.type);
return assignChanged(a, { type });
});
return assignChanged(val, {
arguments: args,
});
}
show(val: a.ShowStatement): a.Statement | nil {

@@ -368,0 +382,0 @@ return val;

@@ -44,2 +44,3 @@ // import { IType } from '../../interfaces';

| CreateFunctionStatement
| DropFunctionStatement
| DoStatement

@@ -83,2 +84,9 @@ | BeginStatement

export interface DropFunctionStatement extends PGNode {
type: 'drop function';
ifExists?: boolean;
name: QName;
arguments?: { name?: Name; type: DataTypeDef }[];
}
export interface ReturnsTable extends PGNode {

@@ -85,0 +93,0 @@ kind: 'table';

@@ -38,7 +38,7 @@ import 'mocha';

checkStatement(`CREATE FUNCTION fn(i integer = 2) AS 'code' LANGUAGE SQL`, {
type: 'create function',
name: { name: 'fn' },
arguments: [{ type: integer, name: { name: 'i' }, default: { type: 'integer', value: 2 }}],
code: 'code',
language: { name: 'sql' },
type: 'create function',
name: { name: 'fn' },
arguments: [{ type: integer, name: { name: 'i' }, default: { type: 'integer', value: 2 } }],
code: 'code',
language: { name: 'sql' },
});

@@ -166,3 +166,3 @@

it ('is not greedy', () => {
it('is not greedy', () => {
const parsed = parse(`create function foo() returns text as $$ select 'hi'; $$ language sql;

@@ -172,2 +172,42 @@ create function bar() returns text as $$ select 'there'; $$ language sql;`);

});
checkStatement('drop function my_function', {
type: 'drop function',
name: { name: 'my_function' },
});
checkStatement('drop function if exists my_function', {
type: 'drop function',
ifExists: true,
name: { name: 'my_function' },
});
checkStatement('drop function my_function(text)', {
type: 'drop function',
name: { name: 'my_function' },
arguments: [{ type: { name: 'text' } }]
});
checkStatement('drop function my_function(text, float)', {
type: 'drop function',
name: { name: 'my_function' },
arguments: [{
type: { name: 'text' },
}, {
type: { name: 'float' },
}]
});
checkStatement('drop function my_function(txt text, fl float)', {
type: 'drop function',
name: { name: 'my_function' },
arguments: [{
type: { name: 'text' },
name: { name: 'txt' },
}, {
type: { name: 'float' },
name: { name: 'fl' },
}]
});
});

@@ -749,2 +749,22 @@ import { IAstPartialMapper, AstDefaultMapper } from './ast-mapper';

dropFunction: d => {
ret.push('DROP FUNCTION ');
if (d.ifExists) {
ret.push('IF EXISTS ');
}
visitQualifiedName(d.name);
if (d.arguments) {
list(d.arguments, a => {
if (a.name) {
visitQualifiedName(a.name);
ret.push(' ');
}
m.dataType(a.type);
}, true);
}
ret.push(' ');
},
with: w => {

@@ -751,0 +771,0 @@ ret.push('WITH ');

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 | DeleteStatement | WithStatement | RollbackStatement | TablespaceStatement | CreateViewStatement | CreateMaterializedViewStatement | AlterTableStatement | AlterSequenceStatement | SetGlobalStatement | SetTimezone | CreateEnumType | CreateCompositeType | TruncateTableStatement | DropTableStatement | DropSequenceStatement | DropIndexStatement | CommentStatement | CreateSchemaStatement | WithRecursiveStatement | RaiseStatement | ValuesStatement | CreateFunctionStatement | DoStatement | BeginStatement | StartTransactionStatement;
export declare type Statement = SelectStatement | CreateTableStatement | CreateSequenceStatement | CreateIndexStatement | CreateExtensionStatement | CommitStatement | InsertStatement | UpdateStatement | ShowStatement | PrepareStatement | 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 interface PGNode {

@@ -33,2 +33,11 @@ _location?: NodeLocation;

}
export interface DropFunctionStatement extends PGNode {
type: 'drop function';
ifExists?: boolean;
name: QName;
arguments?: {
name?: Name;
type: DataTypeDef;
}[];
}
export interface ReturnsTable extends PGNode {

@@ -35,0 +44,0 @@ kind: '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

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc