Skip to content

Commit f048b0f

Browse files
committed
Fix null type
1 parent 8890904 commit f048b0f

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

cjs/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
22
"name": "peegee",
3-
"version": "0.0.8",
3+
"version": "0.0.9",
44
"description": "Fastest full featured PostgreSQL client for Node.js",
55
"main": "lib/index.js",
66
"type": "commonjs",
77
"scripts": {
88
"test": "node tests/index.js",
9-
"prepublishOnly": "eslint lib && npm run build",
9+
"prepublishOnly": "eslint lib && npm test && npm run build",
1010
"build": "node cjs/transpile.js"
1111
},
1212
"author": "Rasmus Porsager <rasmus@porsager.com",

lib/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ export default function Postgres(url, options) {
413413

414414
function getType(x) {
415415
if (x == null)
416-
return { type: types.string.to, value: x }
416+
return { type: 0, value: x }
417417

418418
const value = x.type ? x.value : x
419419
, type = x.array ? typeArrayMap[x.type || inferType(value)] : (x.type || inferType(value))

tests/index.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,11 @@ t('Escape in arrays', async() =>
112112
['Hello "you",c:\\windows', (await sql`select ${ sql.array(['Hello "you"', 'c:\\windows']) } as x`)[0].x.join(',')]
113113
)
114114

115+
t('null for int', async() => {
116+
await sql`create table test (x int)`
117+
return [1, (await sql`insert into test values(${ null })`).count]
118+
}, () => sql`drop table test`)
119+
115120
t('Transaction throws', async() => {
116121
await sql`create table test (a int)`
117122
return ['22P02', await sql.begin(async sql => {
@@ -243,7 +248,7 @@ t('Point type array', async() => {
243248
}, () => sql`drop table test`)
244249

245250
t('sql file', async() =>
246-
[1, (await sql.file('./select.sql'))[0].x]
251+
[1, (await sql.file('./tests/select.sql'))[0].x]
247252
)
248253
/*
249254
t('select column vars', async() => {
@@ -254,7 +259,7 @@ t('select column vars', async() => {
254259
*/
255260
t('sql file can stream', async() => {
256261
let result
257-
await sql.file('./select.sql')
262+
await sql.file('./tests/select.sql')
258263
.stream(({ x }) => result = x)
259264

260265
return [1, result]

0 commit comments

Comments
 (0)