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 1.5.1 to 2.0.0

2

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

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

@@ -64,3 +64,3 @@ import 'mocha';

name: 'a',
dataType: { type: 'jsonb' },
dataType: { name: 'jsonb' },
constraints: [{ type: 'not null' }],

@@ -79,3 +79,3 @@ },

name: 'a',
dataType: { type: 'jsonb' },
dataType: { name: 'jsonb' },
constraints: [{ type: 'not null' }],

@@ -113,3 +113,3 @@ },

type: 'set type',
dataType: { type: 'jsonb' },
dataType: { name: 'jsonb' },
}

@@ -116,0 +116,0 @@ }

@@ -266,6 +266,12 @@ // import { IType } from '../../interfaces';

export interface DataTypeDef {
type: string;
export type DataTypeDef = ArrayDataTypeDef | BasicDataTypeDef;
export interface ArrayDataTypeDef {
kind: 'array';
arrayOf: DataTypeDef;
}
export interface BasicDataTypeDef extends QName {
kind?: undefined;
length?: number;
arrayOf?: DataTypeDef;
}

@@ -272,0 +278,0 @@

@@ -12,6 +12,31 @@ import 'mocha';

name: 'value',
dataType: { type: 'text' },
dataType: { name: 'text' },
}],
});
checkCreateTable(['create table test(value pg_catalog.text)'], {
type: 'create table',
name: 'test',
columns: [{
name: 'value',
dataType: {
name: 'text',
schema: 'pg_catalog',
},
}],
});
checkCreateTable(['create table test(value pg_catalog.varchar(12))'], {
type: 'create table',
name: 'test',
columns: [{
name: 'value',
dataType: {
schema: 'pg_catalog',
name: 'varchar',
length: 12,
},
}],
});
checkCreateTable(['create table if not exists test(value text)'], {

@@ -23,3 +48,3 @@ type: 'create table',

name: 'value',
dataType: { type: 'text' },
dataType: { name: 'text' },
}],

@@ -33,3 +58,3 @@ });

name: 'value',
dataType: { type: 'text' },
dataType: { name: 'text' },
constraints: [{ type: 'primary key' }],

@@ -45,3 +70,3 @@ }],

name: 'value',
dataType: { type: 'text' },
dataType: { name: 'text' },
constraints: [{ type: 'unique' }],

@@ -57,3 +82,3 @@ }],

name: 'value',
dataType: { type: 'text' },
dataType: { name: 'text' },
constraints: [{ type: 'unique' }, { type: 'not null' }],

@@ -69,3 +94,6 @@ }],

name: 'value',
dataType: { type: 'array', arrayOf: { type: 'text' } },
dataType: {
kind: 'array',
arrayOf: { name: 'text' }
},
}],

@@ -81,6 +109,6 @@ });

dataType: {
type: 'array',
kind: 'array',
arrayOf: {
type: 'array',
arrayOf: { type: 'text' }
kind: 'array',
arrayOf: { name: 'text' }
}

@@ -96,3 +124,3 @@ },

name: 'value',
dataType: { type: 'timestamp with time zone' },
dataType: { name: 'timestamp with time zone' },
}],

@@ -109,3 +137,3 @@ });

name: 'value',
dataType: { type: 'timestamp' },
dataType: { name: 'timestamp' },
}],

@@ -121,7 +149,7 @@ });

name: 'id',
dataType: { type: 'text' },
dataType: { name: 'text' },
constraints: [{ type: 'primary key' }],
}, {
name: 'value',
dataType: { type: 'text' },
dataType: { name: 'text' },
constraints: [{ type: 'unique' }, { type: 'not null' }],

@@ -136,3 +164,3 @@ }],

name: 'id',
dataType: { type: 'serial' },
dataType: { name: 'serial' },
constraints: [{ type: 'not null' }],

@@ -149,6 +177,6 @@ }],

name: 'a',
dataType: { type: 'text' },
dataType: { name: 'text' },
}, {
name: 'b',
dataType: { type: 'text' },
dataType: { name: 'text' },
}],

@@ -168,3 +196,3 @@ constraints: [{

name: 'price',
dataType: { type: 'numeric' },
dataType: { name: 'numeric' },
constraints: [{

@@ -195,3 +223,3 @@ type: 'check',

name: 'a',
dataType: { type: 'text' },
dataType: { name: 'text' },
}],

@@ -215,3 +243,3 @@ constraints: [{

name: 'a',
dataType: { type: 'text' },
dataType: { name: 'text' },
}],

@@ -235,11 +263,11 @@ constraints: [{

name: 'id',
dataType: { type: 'character varying' },
dataType: { name: 'character varying' },
constraints: [{ type: 'not null' }],
}, {
name: 'b',
dataType: { type: 'text' },
dataType: { name: 'text' },
constraints: [{ type: 'not null' }],
}, {
name: 'c',
dataType: { type: 'character varying' },
dataType: { name: 'character varying' },
constraints: [{ type: 'not null' }],

@@ -249,4 +277,4 @@ }, {

dataType: {
type: 'array',
arrayOf: { type: 'jsonb' }
kind: 'array',
arrayOf: { name: 'jsonb' }
},

@@ -256,3 +284,3 @@ constraints: [{ type: 'not null' }],

name: 'e',
dataType: { type: 'jsonb' },
dataType: { name: 'jsonb' },
constraints: [{ type: 'not null' }],

@@ -281,3 +309,3 @@ }],

name: 'a',
dataType: { type: 'character varying' },
dataType: { name: 'character varying' },
constraints: [{ type: 'not null' }],

@@ -290,3 +318,3 @@ collate: {

name: 'b',
dataType: { type: 'character varying' },
dataType: { name: 'character varying' },
constraints: [{ type: 'not null' }],

@@ -310,3 +338,3 @@ collate: {

name: 'feature',
dataType: { type: 'text' },
dataType: { name: 'text' },
constraints: [{

@@ -316,3 +344,3 @@ type: 'default',

type: 'cast',
to: { type: 'text' },
to: { name: 'text' },
operand: {

@@ -339,6 +367,6 @@ type: 'string',

name: 'update_date',
dataType: { type: 'timestamp without time zone' },
dataType: { name: 'timestamp without time zone' },
}, {
name: 'creation_date',
dataType: { type: 'timestamp without time zone' },
dataType: { name: 'timestamp without time zone' },
constraints: [{

@@ -366,3 +394,3 @@ type: 'default',

name: 'categoryid',
dataType: { type: 'text' },
dataType: { name: 'text' },
}],

@@ -401,3 +429,3 @@ constraints: [{

columns: [{
dataType: { type: 'int' },
dataType: { name: 'int' },
name: 'color_id',

@@ -418,3 +446,3 @@ constraints: [{

columns: [{
dataType: { type: 'int' },
dataType: { name: 'int' },
name: 'color_id',

@@ -421,0 +449,0 @@ constraints: [{

@@ -195,3 +195,3 @@ import 'mocha';

type: 'cast',
to: { type: 'jsonb' },
to: { name: 'jsonb' },
operand: {

@@ -206,3 +206,3 @@ type: 'ref',

type: 'cast',
to: { type: 'json' },
to: { name: 'json' },
operand: {

@@ -214,3 +214,3 @@ type: 'member',

type: 'cast',
to: { type: 'jsonb' },
to: { name: 'jsonb' },
operand: {

@@ -459,3 +459,3 @@ type: 'ref',

type: 'cast',
to: { type: 'jsonb' },
to: { name: 'jsonb' },
operand: {

@@ -477,3 +477,3 @@ type: 'ref',

type: 'cast',
to: { type: 'JSONB' },
to: { name: 'JSONB' },
operand: {

@@ -488,3 +488,3 @@ type: 'ref',

type: 'cast',
to: { type: 'jsonb' },
to: { name: 'jsonb' },
operand: {

@@ -491,0 +491,0 @@ type: 'binary',

@@ -290,3 +290,3 @@ import 'mocha';

},
to: { type: 'time without time zone' },
to: { name: 'time without time zone' },
}

@@ -293,0 +293,0 @@ }]

@@ -20,3 +20,3 @@ import 'mocha';

cache: 1,
as: { type: 'bigint' },
as: { name: 'bigint' },
cycle: 'cycle',

@@ -23,0 +23,0 @@ }

@@ -499,7 +499,3 @@ import { IAstPartialMapper, AstDefaultMapper } from './ast-mapper';

dataType: d => {
if (!d?.type) {
ret.push('unkown');
return;
}
if (d.type === 'array') {
if (d?.kind === 'array') {
m.dataType(d.arrayOf!)

@@ -509,6 +505,10 @@ ret.push('[]');

}
const tname = d.length
? (d.type + '(' + d.length + ')')
: d.type;
ret.push(name(tname));
if (!d?.name) {
ret.push('unkown');
return;
}
visitQualifiedName(d);
if (d.length) {
ret.push('(', d.length.toString(), ')');
}
},

@@ -515,0 +515,0 @@

@@ -195,6 +195,10 @@ import { nil } from '../utils';

}
export interface DataTypeDef {
type: string;
export declare type DataTypeDef = ArrayDataTypeDef | BasicDataTypeDef;
export interface ArrayDataTypeDef {
kind: 'array';
arrayOf: DataTypeDef;
}
export interface BasicDataTypeDef extends QName {
kind?: undefined;
length?: number;
arrayOf?: DataTypeDef;
}

@@ -201,0 +205,0 @@ export declare type ColumnConstraint = ColumnConstraintSimple | ColumnConstraintDefault | AlterColumnAddGenerated | ColumnConstraintCheck;

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

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