pgsql-ast-parser
Advanced tools
Comparing version 9.2.0 to 9.2.1
{ | ||
"name": "pgsql-ast-parser", | ||
"version": "9.2.0", | ||
"version": "9.2.1", | ||
"description": "Yet another simple Postgres SQL parser/modifier", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -248,2 +248,3 @@ // import { IType } from '../../interfaces'; | ||
}; | ||
where?: Expr; | ||
} | ||
@@ -580,2 +581,3 @@ | ||
order?: 'ASC' | 'DESC' | nil; | ||
nulls?: 'FIRST' | 'LAST' | nil; | ||
} | ||
@@ -582,0 +584,0 @@ |
@@ -103,2 +103,25 @@ import 'mocha'; | ||
checkInsert([`insert into test(a) values (1) on conflict do update set a=3 WHERE v`], { | ||
type: 'insert', | ||
into: { name: 'test' }, | ||
columns: [{ name: 'a' }], | ||
insert: { | ||
type: 'values', | ||
values: [[{ | ||
type: 'integer', | ||
value: 1, | ||
},]] | ||
}, | ||
onConflict: { | ||
do: { | ||
sets: [{ | ||
column: { name: 'a' }, | ||
value: { type: 'integer', value: 3 }, | ||
}] | ||
}, | ||
where: { type: 'ref', name: 'v' }, | ||
}, | ||
}); | ||
checkInsert([`insert into test values (1) returning "id";`], { | ||
@@ -105,0 +128,0 @@ type: 'insert', |
@@ -179,2 +179,24 @@ import 'mocha'; | ||
checkSelect(['select * from test order by a asc nulls first'], { | ||
type: 'select', | ||
from: [tbl('test')], | ||
columns: columns({ type: 'ref', name: '*' }), | ||
orderBy: [{ | ||
by: { type: 'ref', name: 'a' }, | ||
order: 'ASC', | ||
nulls: 'FIRST', | ||
}] | ||
}); | ||
checkSelect(['select * from test order by a asc nulls last'], { | ||
type: 'select', | ||
from: [tbl('test')], | ||
columns: columns({ type: 'ref', name: '*' }), | ||
orderBy: [{ | ||
by: { type: 'ref', name: 'a' }, | ||
order: 'ASC', | ||
nulls: 'LAST', | ||
}] | ||
}); | ||
checkSelect(['select a.*, b.*'], { | ||
@@ -181,0 +203,0 @@ type: 'select', |
@@ -115,4 +115,7 @@ import { IAstPartialMapper, AstDefaultMapper } from './ast-mapper'; | ||
if (e.order) { | ||
ret.push(' ', e.order); | ||
ret.push(' ', e.order, ' '); | ||
} | ||
if (e.nulls) { | ||
ret.push(' NULLS ', e.nulls, ' ') | ||
} | ||
}, false); | ||
@@ -1090,2 +1093,6 @@ } | ||
list(i.onConflict.do.sets, s => m.set(s), false); | ||
if (i.onConflict.where) { | ||
ret.push(' WHERE '); | ||
m.expr(i.onConflict.where); | ||
} | ||
} | ||
@@ -1092,0 +1099,0 @@ ret.push(' '); |
@@ -173,2 +173,3 @@ import { nil } from '../utils'; | ||
}; | ||
where?: Expr; | ||
} | ||
@@ -422,2 +423,3 @@ export interface AlterTableStatement extends PGNode { | ||
order?: 'ASC' | 'DESC' | nil; | ||
nulls?: 'FIRST' | 'LAST' | nil; | ||
} | ||
@@ -424,0 +426,0 @@ export interface ForStatement extends PGNode { |
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
1505396
16601