pgsql-ast-parser
Advanced tools
Comparing version 10.2.0 to 10.3.0
{ | ||
"name": "pgsql-ast-parser", | ||
"version": "10.2.0", | ||
"version": "10.3.0", | ||
"description": "Yet another simple Postgres SQL parser/modifier", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -491,2 +491,5 @@ // import { IType } from '../../interfaces'; | ||
kind?: undefined; | ||
/** tells if this is a well known type like [timestamp with timezone]. | ||
* This property enables you to differentialte those from their double-quoted counterparts */ | ||
special?: boolean; | ||
/** varchar(length), numeric(precision, scale), ... */ | ||
@@ -493,0 +496,0 @@ config?: number[]; |
@@ -283,2 +283,12 @@ import 'mocha'; | ||
name: { name: 'value' }, | ||
dataType: { name: 'timestamp with time zone', special: true }, | ||
}], | ||
}); | ||
checkCreateTable(['create table"test"(value "timestamp with time zone")'], { | ||
type: 'create table', | ||
name: { name: 'test', }, | ||
columns: [{ | ||
kind: 'column', | ||
name: { name: 'value' }, | ||
dataType: { name: 'timestamp with time zone' }, | ||
@@ -425,3 +435,3 @@ }], | ||
name: { name: 'id' }, | ||
dataType: { name: 'character varying' }, | ||
dataType: { name: 'character varying', special: true }, | ||
constraints: [{ type: 'not null' }], | ||
@@ -436,3 +446,3 @@ }, { | ||
name: { name: 'c' }, | ||
dataType: { name: 'character varying' }, | ||
dataType: { name: 'character varying', special: true }, | ||
constraints: [{ type: 'not null' }], | ||
@@ -477,3 +487,3 @@ }, { | ||
name: { name: 'a' }, | ||
dataType: { name: 'character varying' }, | ||
dataType: { name: 'character varying', special: true }, | ||
constraints: [{ type: 'not null' }], | ||
@@ -487,3 +497,3 @@ collate: { | ||
name: { name: 'b' }, | ||
dataType: { name: 'character varying' }, | ||
dataType: { name: 'character varying', special: true }, | ||
constraints: [{ type: 'not null' }], | ||
@@ -540,7 +550,7 @@ collate: { | ||
name: { name: 'update_date' }, | ||
dataType: { name: 'timestamp without time zone' }, | ||
dataType: { name: 'timestamp without time zone', special: true }, | ||
}, { | ||
kind: 'column', | ||
name: { name: 'creation_date' }, | ||
dataType: { name: 'timestamp without time zone' }, | ||
dataType: { name: 'timestamp without time zone', special: true }, | ||
constraints: [{ | ||
@@ -547,0 +557,0 @@ type: 'default', |
@@ -27,3 +27,3 @@ import 'mocha'; | ||
name: { name: 'value' }, | ||
dataType: { name: 'double precision' }, | ||
dataType: { name: 'double precision', special: true }, | ||
collate: { name: 'abc' }, | ||
@@ -30,0 +30,0 @@ }, |
@@ -604,3 +604,3 @@ import 'mocha'; | ||
operand: { type: 'string', value: '1' }, | ||
to: { name: 'double precision' }, | ||
to: { name: 'double precision', special: true }, | ||
}); | ||
@@ -617,3 +617,3 @@ | ||
operand: { type: 'string', value: '1' }, | ||
to: { name: 'double precision' }, | ||
to: { name: 'double precision', special: true }, | ||
}); | ||
@@ -708,2 +708,3 @@ | ||
config: [4], | ||
special: true, | ||
}, | ||
@@ -710,0 +711,0 @@ operand: { |
@@ -338,3 +338,3 @@ import 'mocha'; | ||
, buildJoin('CROSS JOIN')); | ||
// implicit cross join | ||
@@ -400,3 +400,3 @@ checkSelect('select * from ta, tb where ta.id=tb.id', | ||
columns: [{ expr: star }], | ||
from: [ tbl('td') ], | ||
from: [tbl('td')], | ||
}, | ||
@@ -490,3 +490,3 @@ }, | ||
operand: { type: 'string', value: '1' }, | ||
to: { name: 'double precision' }, | ||
to: { name: 'double precision', special: true }, | ||
} | ||
@@ -504,3 +504,3 @@ }] | ||
operand: { type: 'string', value: '1' }, | ||
to: { name: 'double precision' }, | ||
to: { name: 'double precision', special: true }, | ||
} | ||
@@ -520,3 +520,3 @@ }] | ||
}, | ||
to: { name: 'time without time zone' }, | ||
to: { name: 'time without time zone', special: true }, | ||
} | ||
@@ -523,0 +523,0 @@ }] |
@@ -825,28 +825,32 @@ import { IAstPartialMapper, AstDefaultMapper } from './ast-mapper'; | ||
} else { | ||
// see https://www.postgresql.org/docs/13/datatype.html | ||
// & issue https://github.com/oguimbal/pgsql-ast-parser/issues/38 | ||
switch (d.name) { | ||
case 'double precision': | ||
case 'character varying': | ||
case 'bit varying': | ||
ret.push(d.name, ' '); | ||
break; | ||
case 'time without time zone': | ||
case 'timestamp without time zone': | ||
case 'time with time zone': | ||
case 'timestamp with time zone': | ||
const parts = d.name.split(' '); | ||
if (!d.special) { | ||
visitQualifiedName(d); | ||
} else { | ||
// see https://www.postgresql.org/docs/13/datatype.html | ||
// & issue https://github.com/oguimbal/pgsql-ast-parser/issues/38 | ||
switch (d.name) { | ||
case 'double precision': | ||
case 'character varying': | ||
case 'bit varying': | ||
ret.push(d.name, ' '); | ||
break; | ||
case 'time without time zone': | ||
case 'timestamp without time zone': | ||
case 'time with time zone': | ||
case 'timestamp with time zone': | ||
const parts = d.name.split(' '); | ||
ret.push(parts.shift()!); | ||
if (d.config?.length) { | ||
list(d.config, v => ret.push(v.toString(10)), true); | ||
} | ||
ret.push(' '); | ||
ret.push(parts.shift()!); | ||
if (d.config?.length) { | ||
list(d.config, v => ret.push(v.toString(10)), true); | ||
} | ||
ret.push(' '); | ||
ret.push(parts.join(' '), ' '); | ||
appendConfig = false; | ||
break; | ||
default: | ||
visitQualifiedName(d); | ||
break; | ||
ret.push(parts.join(' '), ' '); | ||
appendConfig = false; | ||
break; | ||
default: | ||
visitQualifiedName(d); | ||
break; | ||
} | ||
} | ||
@@ -853,0 +857,0 @@ } |
@@ -365,2 +365,5 @@ import { nil } from '../utils'; | ||
kind?: undefined; | ||
/** tells if this is a well known type like [timestamp with timezone]. | ||
* This property enables you to differentialte those from their double-quoted counterparts */ | ||
special?: boolean; | ||
/** varchar(length), numeric(precision, scale), ... */ | ||
@@ -367,0 +370,0 @@ config?: number[]; |
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
1606630
17367