pgsql-ast-parser
Advanced tools
Comparing version 6.1.0 to 6.2.0
{ | ||
"name": "pgsql-ast-parser", | ||
"version": "6.1.0", | ||
"version": "6.2.0", | ||
"description": "Yet another simple Postgres SQL parser/modifier", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -1,2 +0,2 @@ | ||
export declare function literal(val: any): string; | ||
export declare function literal(val: string): string; | ||
//# sourceMappingURL=pg-escape.d.ts.map |
// stolen from https://github.com/segmentio/pg-escape/blob/master/index.js | ||
export function literal(val: any) { | ||
export function literal(val: string) { | ||
if (null == val) return 'NULL'; | ||
@@ -5,0 +5,0 @@ if (Array.isArray(val)) { |
@@ -56,3 +56,3 @@ // import { IType } from '../../interfaces'; | ||
type: 'do'; | ||
language?: string; | ||
language?: Name; | ||
code: string; | ||
@@ -66,3 +66,3 @@ } | ||
orReplace?: boolean; | ||
language?: string; | ||
language?: Name; | ||
arguments: FunctionArgument[]; | ||
@@ -139,6 +139,10 @@ returns?: DataTypeDef | ReturnsTable; | ||
name: QName; | ||
values: string[]; | ||
values: Literal[]; | ||
} | ||
export interface Literal extends PGNode { | ||
value: string | ||
} | ||
export interface ShowStatement extends PGNode { | ||
@@ -349,4 +353,4 @@ type: 'show'; | ||
schema?: Name; | ||
version?: string; | ||
from?: string; | ||
version?: Literal; | ||
from?: Literal; | ||
} | ||
@@ -364,3 +368,3 @@ | ||
export interface CreateViewStatementBase extends PGNode { | ||
columnNames?: string[]; | ||
columnNames?: Name[]; | ||
name: QName; | ||
@@ -572,3 +576,3 @@ query: SelectStatement; | ||
values: Expr[][]; | ||
columnNames?: string[] | nil; | ||
columnNames?: Name[] | nil; | ||
join?: JoinClause | nil; | ||
@@ -747,3 +751,3 @@ } | ||
type: 'extract'; | ||
field: string; | ||
field: Name; | ||
from: Expr; | ||
@@ -750,0 +754,0 @@ } |
@@ -29,3 +29,3 @@ import 'mocha'; | ||
ifNotExists: true, | ||
version: '1', | ||
version: { value: '1' }, | ||
}); | ||
@@ -36,4 +36,4 @@ | ||
extension: { name: 'blah' }, | ||
from: 'old', | ||
from: { value: 'old' }, | ||
}); | ||
}); |
@@ -10,4 +10,4 @@ import 'mocha'; | ||
name: { name: 'mytype' }, | ||
values: ['a', 'b'], | ||
values: [{ value: 'a' }, { value: 'b' }], | ||
}); | ||
}); |
@@ -21,3 +21,3 @@ import 'mocha'; | ||
name: { name: 'myview' }, | ||
columnNames: ['a', 'b'], | ||
columnNames: [{ name: 'a' }, { name: 'b' }], | ||
orReplace: true, | ||
@@ -36,3 +36,3 @@ query: { | ||
name: { name: 'myview' }, | ||
columnNames: ['a'], | ||
columnNames: [{ name: 'a' }], | ||
query: { | ||
@@ -39,0 +39,0 @@ type: 'select', |
@@ -1051,3 +1051,3 @@ import 'mocha'; | ||
type: 'extract', | ||
field: 'century', | ||
field: { name: 'century' }, | ||
from: { | ||
@@ -1063,3 +1063,6 @@ type: 'cast', | ||
type: 'extract', | ||
field: 'century', | ||
field: { | ||
[LOCATION]: { start: 9, end: 16 }, | ||
name: 'century' | ||
}, | ||
from: { | ||
@@ -1066,0 +1069,0 @@ [LOCATION]: { start: 22, end: 40 }, |
@@ -21,3 +21,3 @@ import 'mocha'; | ||
code: 'select $1 + $2;', | ||
language: 'sql', | ||
language: { name: 'sql' }, | ||
purity: 'immutable', | ||
@@ -34,3 +34,3 @@ onNullInput: 'null', | ||
code: 'code', | ||
language: 'sql', | ||
language: { name: 'sql' }, | ||
}); | ||
@@ -43,3 +43,3 @@ | ||
code: 'code', | ||
language: 'sql', | ||
language: { name: 'sql' }, | ||
}); | ||
@@ -57,3 +57,3 @@ | ||
returns: integer, | ||
language: 'plpgsql', | ||
language: { name: 'plpgsql' }, | ||
purity: 'volatile', | ||
@@ -72,3 +72,3 @@ code: ` | ||
name: { name: 'dup' }, | ||
language: 'sql', | ||
language: { name: 'sql' }, | ||
arguments: [{ | ||
@@ -95,3 +95,3 @@ type: int, | ||
name: { name: 'dup', schema: 'public', }, | ||
language: 'sql', | ||
language: { name: 'sql' }, | ||
arguments: [{ type: int }], | ||
@@ -115,3 +115,3 @@ code: ` SELECT $1, CAST($1 AS text) || ' is text' `, | ||
name: { name: 'fn' }, | ||
language: 'sql', | ||
language: { name: 'sql' }, | ||
arguments: [], | ||
@@ -158,5 +158,5 @@ code: `body`, | ||
type: 'do', | ||
language: 'js', | ||
language: { name: 'js' }, | ||
code: ' something ', | ||
}); | ||
}); |
@@ -374,3 +374,3 @@ import 'mocha'; | ||
alias: { name: 'vals' }, | ||
columnNames: ['num', 'letter'], | ||
columnNames: [{ name: 'num' }, { name: 'letter' }], | ||
values: [ | ||
@@ -377,0 +377,0 @@ [{ type: 'integer', value: 1 }, { type: 'string', value: 'one' }], |
@@ -227,6 +227,6 @@ import { IAstPartialMapper, AstDefaultMapper } from './ast-mapper'; | ||
if (e.version) { | ||
ret.push(' VERSION ', literal(e.version)); | ||
ret.push(' VERSION ', literal(e.version.value)); | ||
} | ||
if (e.from) { | ||
ret.push(' FROM ', literal(e.from)); | ||
ret.push(' FROM ', literal(e.from.value)); | ||
} | ||
@@ -265,3 +265,3 @@ }, | ||
ret.push(' AS ENUM '); | ||
list(t.values, x => ret.push(literal(x)), true); | ||
list(t.values, x => ret.push(literal(x.value)), true); | ||
ret.push(' '); | ||
@@ -435,3 +435,3 @@ }, | ||
extract: v => { | ||
ret.push('EXTRACT (', v.field.toUpperCase(), ' FROM '); | ||
ret.push('EXTRACT (', v.field.name.toUpperCase(), ' FROM '); | ||
m.expr(v.from); | ||
@@ -549,3 +549,3 @@ ret.push(') '); | ||
if (d.language) { | ||
ret.push(' LANGUAGE ', d.language); | ||
ret.push(' LANGUAGE ', d.language.name); | ||
} | ||
@@ -596,3 +596,3 @@ ret.push(' $$', d.code, '$$'); | ||
if (c.language) { | ||
ret.push('LANGUAGE ', c.language, ' '); | ||
ret.push('LANGUAGE ', c.language.name, ' '); | ||
} | ||
@@ -827,3 +827,3 @@ if (c.purity) { | ||
if (s.columnNames) { | ||
list(s.columnNames, s => ret.push(s), true); | ||
list(s.columnNames, s => ret.push(name(s)), true); | ||
} | ||
@@ -972,3 +972,3 @@ }); | ||
if (c.columnNames) { | ||
list(c.columnNames, c => ret.push(c), true); | ||
list(c.columnNames, c => ret.push(name(c)), true); | ||
} | ||
@@ -994,3 +994,3 @@ const opts = c.parameters && Object.entries(c.parameters); | ||
if (c.columnNames) { | ||
list(c.columnNames, c => ret.push(c), true); | ||
list(c.columnNames, c => ret.push(name(c)), true); | ||
} | ||
@@ -997,0 +997,0 @@ const opts = c.parameters && Object.entries(c.parameters); |
@@ -13,3 +13,3 @@ import { nil } from '../utils'; | ||
type: 'do'; | ||
language?: string; | ||
language?: Name; | ||
code: string; | ||
@@ -22,3 +22,3 @@ } | ||
orReplace?: boolean; | ||
language?: string; | ||
language?: Name; | ||
arguments: FunctionArgument[]; | ||
@@ -82,4 +82,7 @@ returns?: DataTypeDef | ReturnsTable; | ||
name: QName; | ||
values: string[]; | ||
values: Literal[]; | ||
} | ||
export interface Literal extends PGNode { | ||
value: string; | ||
} | ||
export interface ShowStatement extends PGNode { | ||
@@ -248,4 +251,4 @@ type: 'show'; | ||
schema?: Name; | ||
version?: string; | ||
from?: string; | ||
version?: Literal; | ||
from?: Literal; | ||
} | ||
@@ -260,3 +263,3 @@ export interface IndexExpression extends PGNode { | ||
export interface CreateViewStatementBase extends PGNode { | ||
columnNames?: string[]; | ||
columnNames?: Name[]; | ||
name: QName; | ||
@@ -418,3 +421,3 @@ query: SelectStatement; | ||
values: Expr[][]; | ||
columnNames?: string[] | nil; | ||
columnNames?: Name[] | nil; | ||
join?: JoinClause | nil; | ||
@@ -523,3 +526,3 @@ } | ||
type: 'extract'; | ||
field: string; | ||
field: Name; | ||
from: Expr; | ||
@@ -526,0 +529,0 @@ } |
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
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
Sorry, the diff of this file is not supported yet
1308299
14407