@databases/mysql
Advanced tools
Comparing version 5.2.1 to 6.0.0-canary-2423
@@ -7,3 +7,3 @@ "use strict"; | ||
const db = (0, __1.default)(); | ||
await db.query((0, __1.sql) `CREATE TABLE bigint_test_bigints (id INT NOT NULL PRIMARY KEY, test_value BIGINT NOT NULL);`); | ||
await db.query((0, __1.sql) `CREATE TABLE bigint_test_bigints (id INT NOT NULL PRIMARY KEY, test_value BIGINT);`); | ||
await db.query((0, __1.sql) ` | ||
@@ -15,3 +15,4 @@ INSERT INTO bigint_test_bigints (id, test_value) | ||
(4, ${Number.MAX_SAFE_INTEGER}), | ||
(5, ${'9999999999999999'}); | ||
(5, ${'9999999999999999'}), | ||
(6, null); | ||
`); | ||
@@ -32,2 +33,3 @@ await db.dispose(); | ||
{ id: 5, test_value: 10000000000000000 }, | ||
{ id: 6, test_value: null }, | ||
]); | ||
@@ -47,2 +49,3 @@ await db.dispose(); | ||
{ id: 5, test_value: '9999999999999999' }, | ||
{ id: 6, test_value: null }, | ||
]); | ||
@@ -62,2 +65,3 @@ await db.dispose(); | ||
{ id: 5, test_value: BigInt('9999999999999999') }, | ||
{ id: 6, test_value: null }, | ||
]); | ||
@@ -64,0 +68,0 @@ await db.dispose(); |
@@ -7,3 +7,3 @@ "use strict"; | ||
const db = (0, __1.default)(); | ||
await db.query((0, __1.sql) `CREATE TABLE booleans_test_booleans (id INT NOT NULL PRIMARY KEY, test_value BOOLEAN NOT NULL);`); | ||
await db.query((0, __1.sql) `CREATE TABLE booleans_test_booleans (id INT NOT NULL PRIMARY KEY, test_value BOOLEAN);`); | ||
await db.query((0, __1.sql) ` | ||
@@ -13,3 +13,4 @@ INSERT INTO booleans_test_booleans (id, test_value) | ||
(2, ${false}), | ||
(3, 42); | ||
(3, 42), | ||
(4, null); | ||
`); | ||
@@ -27,2 +28,3 @@ await db.dispose(); | ||
{ id: 3, test_value: 42 }, | ||
{ id: 4, test_value: null }, | ||
]); | ||
@@ -40,2 +42,3 @@ await db.dispose(); | ||
{ id: 3, test_value: true }, | ||
{ id: 4, test_value: null }, | ||
]); | ||
@@ -42,0 +45,0 @@ await db.dispose(); |
@@ -399,2 +399,26 @@ "use strict"; | ||
}); | ||
test('DATE NULL', async () => { | ||
const db = (0, __1.default)({ timeZone: { client: 'utc' } }); | ||
await db.query((0, __1.sql) ` | ||
DROP TABLE IF EXISTS dates_test_pure_dates; | ||
CREATE TABLE dates_test_pure_dates ( | ||
id INT NOT NULL PRIMARY KEY, | ||
date_value DATE | ||
); | ||
INSERT INTO dates_test_pure_dates (id, date_value) | ||
VALUES (1, null), | ||
(2, ${'2000-06-04'}); | ||
`); | ||
expect(await db.query((0, __1.sql) `SELECT * from dates_test_pure_dates`)).toEqual([ | ||
{ | ||
date_value: null, | ||
id: 1, | ||
}, | ||
{ | ||
date_value: new Date('2000-06-04T00:00:00.000Z'), | ||
id: 2, | ||
}, | ||
]); | ||
await db.dispose(); | ||
}); | ||
test('timestamp NULL', async () => { | ||
@@ -401,0 +425,0 @@ await db.task(async (db) => { |
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
import { Readable } from 'stream'; | ||
@@ -3,0 +4,0 @@ import { BaseConnectionPool, PoolOptions } from '@databases/shared'; |
@@ -78,8 +78,14 @@ "use strict"; | ||
} | ||
function parseNullable(value, parser) { | ||
if (value == null) { | ||
return null; | ||
} | ||
return parser(value); | ||
} | ||
function getTinyIntParser(mode) { | ||
switch (mode) { | ||
case 'number': | ||
return (f) => parseInt(f.string(), 10); | ||
return (f) => parseNullable(f.string(), (s) => parseInt(s, 10)); | ||
case 'boolean': | ||
return (f) => f.string() !== '0'; | ||
return (f) => parseNullable(f.string(), (s) => s !== '0'); | ||
} | ||
@@ -90,7 +96,7 @@ } | ||
case 'number': | ||
return (f) => parseInt(f.string(), 10); | ||
return (f) => parseNullable(f.string(), (s) => parseInt(s, 10)); | ||
case 'string': | ||
return (f) => f.string(); | ||
case 'bigint': | ||
return (f) => BigInt(f.string()); | ||
return (f) => parseNullable(f.string(), (s) => BigInt(s)); | ||
} | ||
@@ -103,4 +109,4 @@ } | ||
case 'date-object': | ||
return (f) => { | ||
const match = /^(\d{4})\-(\d{2})\-(\d{2})$/.exec(f.string()); | ||
return (f) => parseNullable(f.string(), (s) => { | ||
const match = /^(\d{4})\-(\d{2})\-(\d{2})$/.exec(s); | ||
if (!match) { | ||
@@ -115,3 +121,3 @@ throw new Error('Expected yyyy-mm-dd'); | ||
} | ||
}; | ||
}); | ||
} | ||
@@ -118,0 +124,0 @@ } |
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
import { ReadableOptions } from 'stream'; | ||
@@ -3,0 +4,0 @@ export interface ColumnDefinition { |
{ | ||
"name": "@databases/mysql", | ||
"version": "5.2.1", | ||
"version": "6.0.0-canary-2423", | ||
"description": "", | ||
@@ -9,7 +9,7 @@ "main": "./lib/index.js", | ||
"@babel/code-frame": "^7.0.0", | ||
"@databases/escape-identifier": "^1.0.3", | ||
"@databases/mysql-config": "^3.0.0", | ||
"@databases/push-to-async-iterable": "^3.0.0", | ||
"@databases/shared": "^3.0.0", | ||
"@databases/sql": "^3.2.0", | ||
"@databases/escape-identifier": "1.0.3", | ||
"@databases/mysql-config": "3.2.0", | ||
"@databases/push-to-async-iterable": "3.0.0", | ||
"@databases/shared": "3.0.2", | ||
"@databases/sql": "3.3.0", | ||
"@types/mysql": "^2.15.5", | ||
@@ -16,0 +16,0 @@ "mysql2": "^2.2.5" |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
1559
136618
1
+ Added@databases/shared@3.0.2(transitive)
+ Addedcuid@2.1.8(transitive)
- Removed@databases/shared@3.1.0(transitive)
Updated@databases/shared@3.0.2
Updated@databases/sql@3.3.0