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 2.1.1 to 2.2.0

src/syntax/with.ne

2

ast-mapper.d.ts

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

createColumn?: (col: a.CreateColumnDef) => a.CreateColumnDef | nil;
with?: (val: a.WithStatement) => a.Statement | nil;
selection?: (val: a.SelectStatement) => a.SelectStatement | nil;

@@ -149,2 +150,3 @@ from?: (from: a.From) => a.From | nil;

selection(val: a.SelectStatement): a.SelectStatement | nil;
with(val: a.WithStatement): a.Statement | nil;
from(from: a.From): a.From | nil;

@@ -151,0 +153,0 @@ fromStatement(from: a.FromStatement): a.From | nil;

2

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

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

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

createColumn?: (col: a.CreateColumnDef) => a.CreateColumnDef | nil
with?: (val: a.WithStatement) => a.Statement | nil
selection?: (val: a.SelectStatement) => a.SelectStatement | nil

@@ -154,2 +155,14 @@ from?: (from: a.From) => a.From | nil

function withAccepts(val: a.Statement | nil): val is a.WithStatementBinding {
switch (val?.type) {
case 'select':
case 'delete':
case 'insert':
case 'update':
return true;
default:
return false;
}
}
/**

@@ -188,2 +201,4 @@ * Can be used to modify an AST.

return this.insert(val);
case 'with':
return this.with(val);
case 'select':

@@ -624,3 +639,3 @@ return this.selection(val);

// =========================================
// ============== EXPRESSIONS ==============
// ============== SELECTIONS ==============
// =========================================

@@ -656,3 +671,25 @@

with(val: a.WithStatement): a.Statement | nil {
const bind = arrayNilMap(val.bind, s => {
const statement = this.statement(s.statement);
return withAccepts(statement)
? assignChanged(s, { statement })
: null;
});
// no bindngs
if (!bind) {
return this.statement(val.in);
}
const _in = this.statement(val.in);
if (!withAccepts(_in)) {
return null;
}
return assignChanged(val, {
bind,
in: _in,
})
}
from(from: a.From): a.From | nil {

@@ -659,0 +696,0 @@ switch (from.type) {

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

| DeleteStatement
| WithStatement
| RollbackStatement

@@ -336,2 +337,11 @@ | TablespaceStatement

export type WithStatementBinding = SelectStatement | InsertStatement | UpdateStatement | DeleteStatement;
export interface WithStatement {
type: 'with';
bind: {
alias: string;
statement: WithStatementBinding;
}[];
in: WithStatementBinding;
}

@@ -338,0 +348,0 @@ export interface SelectStatement {

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

with: w => {
ret.push('WITH ');
list(w.bind, b => {
ret.push(name(b.alias), ' AS (');
m.statement(b.statement);
ret.push(') ');
}, false);
m.statement(w.in);
},
setGlobal: g => {

@@ -495,0 +506,0 @@ ret.push('SET ', name(g.variable), ' = ');

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 | SetTimezone | CreateEnumType | TruncateTableStatement | DropTableStatement | DropSequenceStatement | DropIndexStatement | StartTransactionStatement) & {
export declare type Statement = (SelectStatement | CreateTableStatement | CreateSequenceStatement | CreateIndexStatement | CreateExtensionStatement | CommitStatement | InsertStatement | UpdateStatement | DeleteStatement | WithStatement | RollbackStatement | TablespaceStatement | AlterTableStatement | AlterSequenceStatement | SetGlobalStatement | SetTimezone | CreateEnumType | TruncateTableStatement | DropTableStatement | DropSequenceStatement | DropIndexStatement | StartTransactionStatement) & {
[LOCATION]?: StatementLocation;

@@ -239,2 +239,11 @@ };

}
export declare type WithStatementBinding = SelectStatement | InsertStatement | UpdateStatement | DeleteStatement;
export interface WithStatement {
type: 'with';
bind: {
alias: string;
statement: WithStatementBinding;
}[];
in: WithStatementBinding;
}
export interface SelectStatement {

@@ -241,0 +250,0 @@ type: 'select';

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