@databases/mysql
Advanced tools
Comparing version 5.1.0 to 5.1.1
@@ -6,5 +6,5 @@ "use strict"; | ||
beforeAll(async () => { | ||
const db = __1.default(); | ||
await db.query(__1.sql `CREATE TABLE bigint_test_bigints (id INT NOT NULL PRIMARY KEY, test_value BIGINT NOT NULL);`); | ||
await db.query(__1.sql ` | ||
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) ` | ||
INSERT INTO bigint_test_bigints (id, test_value) | ||
@@ -20,4 +20,4 @@ VALUES (1, ${1}), | ||
test('bigints as number', async () => { | ||
const db = __1.default({ bigIntMode: 'number' }); | ||
const result = await db.query(__1.sql ` | ||
const db = (0, __1.default)({ bigIntMode: 'number' }); | ||
const result = await db.query((0, __1.sql) ` | ||
SELECT id, test_value from bigint_test_bigints; | ||
@@ -36,4 +36,4 @@ `); | ||
test('bigints as string', async () => { | ||
const db = __1.default({ bigIntMode: 'string' }); | ||
const result = await db.query(__1.sql ` | ||
const db = (0, __1.default)({ bigIntMode: 'string' }); | ||
const result = await db.query((0, __1.sql) ` | ||
SELECT id, test_value from bigint_test_bigints; | ||
@@ -51,4 +51,4 @@ `); | ||
test('bigints as BigInt', async () => { | ||
const db = __1.default({ bigIntMode: 'bigint' }); | ||
const result = await db.query(__1.sql ` | ||
const db = (0, __1.default)({ bigIntMode: 'bigint' }); | ||
const result = await db.query((0, __1.sql) ` | ||
SELECT id, test_value from bigint_test_bigints; | ||
@@ -55,0 +55,0 @@ `); |
@@ -6,5 +6,5 @@ "use strict"; | ||
beforeAll(async () => { | ||
const db = __1.default(); | ||
await db.query(__1.sql `CREATE TABLE booleans_test_booleans (id INT NOT NULL PRIMARY KEY, test_value BOOLEAN NOT NULL);`); | ||
await db.query(__1.sql ` | ||
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) ` | ||
INSERT INTO booleans_test_booleans (id, test_value) | ||
@@ -18,4 +18,4 @@ VALUES (1, ${true}), | ||
test('booleans as number', async () => { | ||
const db = __1.default({ tinyIntMode: 'number' }); | ||
const result = await db.query(__1.sql ` | ||
const db = (0, __1.default)({ tinyIntMode: 'number' }); | ||
const result = await db.query((0, __1.sql) ` | ||
SELECT id, test_value from booleans_test_booleans; | ||
@@ -31,4 +31,4 @@ `); | ||
test('booleans as boolean', async () => { | ||
const db = __1.default({ tinyIntMode: 'boolean' }); | ||
const result = await db.query(__1.sql ` | ||
const db = (0, __1.default)({ tinyIntMode: 'boolean' }); | ||
const result = await db.query((0, __1.sql) ` | ||
SELECT id, test_value from booleans_test_booleans; | ||
@@ -35,0 +35,0 @@ `); |
@@ -6,3 +6,3 @@ "use strict"; | ||
jest.setTimeout(30000); | ||
const db = __1.default(); | ||
const db = (0, __1.default)(); | ||
const rawConnection = mysql.createConnection({ | ||
@@ -26,4 +26,4 @@ uri: process.env.MYSQL_URL, | ||
await db.task(async (db) => { | ||
await db.query(__1.sql `SET time_zone = "+00:00";`); | ||
await db.query(__1.sql ` | ||
await db.query((0, __1.sql) `SET time_zone = "+00:00";`); | ||
await db.query((0, __1.sql) ` | ||
DROP TABLE IF EXISTS dates_test_dates; | ||
@@ -44,3 +44,3 @@ CREATE TABLE dates_test_dates ( | ||
const sampleDate = new Date('2000-06-03T05:40:10.123Z'); | ||
await db.query(__1.sql ` | ||
await db.query((0, __1.sql) ` | ||
INSERT INTO dates_test_dates (id, a, b, c, d) | ||
@@ -50,3 +50,3 @@ VALUES (1, ${sampleDate}, ${sampleDate}, ${sampleDate}, ${2000}), | ||
`); | ||
await db.query(__1.sql ` | ||
await db.query((0, __1.sql) ` | ||
INSERT INTO dates_test_pure_dates (id, date_value) | ||
@@ -92,3 +92,3 @@ VALUES (1, ${'2000-06-03'}), | ||
]); | ||
const result = await db.query(__1.sql ` | ||
const result = await db.query((0, __1.sql) ` | ||
SELECT * from dates_test_dates; | ||
@@ -112,3 +112,3 @@ `); | ||
]); | ||
expect(await db.query(__1.sql ` | ||
expect(await db.query((0, __1.sql) ` | ||
SELECT * from dates_test_pure_dates; | ||
@@ -138,3 +138,3 @@ `)).toEqual([ | ||
await (await rawConnection2).query(`SET time_zone = "+03:00";`); | ||
const db = __1.default({ timeZone: 'local' }); | ||
const db = (0, __1.default)({ timeZone: 'local' }); | ||
await db.task(async (db) => { | ||
@@ -145,3 +145,3 @@ // Setting timezone to match our local timezone means that fields of type `TIMESTAMP` are stored | ||
// The `rawConnection` is still set to UTC, so you can see the actual UTC values being stored. | ||
await db.query(__1.sql ` | ||
await db.query((0, __1.sql) ` | ||
DROP TABLE IF EXISTS dates_test_dates; | ||
@@ -162,3 +162,3 @@ CREATE TABLE dates_test_dates ( | ||
const sampleDate = new Date('2000-06-03T05:40:10.123Z'); | ||
await db.query(__1.sql ` | ||
await db.query((0, __1.sql) ` | ||
INSERT INTO dates_test_dates (id, a, b, c, d) | ||
@@ -168,3 +168,3 @@ VALUES (1, ${sampleDate}, ${sampleDate}, ${sampleDate}, ${2000}), | ||
`); | ||
await db.query(__1.sql ` | ||
await db.query((0, __1.sql) ` | ||
INSERT INTO dates_test_pure_dates (id, date_value) | ||
@@ -210,3 +210,3 @@ VALUES (1, ${'2000-06-03'}), | ||
]); | ||
const result = await db.query(__1.sql ` | ||
const result = await db.query((0, __1.sql) ` | ||
SELECT * from dates_test_dates; | ||
@@ -230,3 +230,3 @@ `); | ||
]); | ||
expect(await db.query(__1.sql ` | ||
expect(await db.query((0, __1.sql) ` | ||
SELECT * from dates_test_pure_dates; | ||
@@ -257,5 +257,5 @@ `)).toEqual([ | ||
await (await rawConnection2).query(`SET time_zone = "+04:00";`); | ||
const db = __1.default({ timeZone: 'utc' }); | ||
const db = (0, __1.default)({ timeZone: 'utc' }); | ||
await db.task(async (db) => { | ||
await db.query(__1.sql ` | ||
await db.query((0, __1.sql) ` | ||
DROP TABLE IF EXISTS dates_test_dates; | ||
@@ -276,3 +276,3 @@ CREATE TABLE dates_test_dates ( | ||
const sampleDate = new Date('2000-06-03T05:40:10.123Z'); | ||
await db.query(__1.sql ` | ||
await db.query((0, __1.sql) ` | ||
INSERT INTO dates_test_dates (id, a, b, c, d) | ||
@@ -282,3 +282,3 @@ VALUES (1, ${sampleDate}, ${sampleDate}, ${sampleDate}, ${2000}), | ||
`); | ||
await db.query(__1.sql ` | ||
await db.query((0, __1.sql) ` | ||
INSERT INTO dates_test_pure_dates (id, date_value) | ||
@@ -324,3 +324,3 @@ VALUES (1, ${'2000-06-03'}), | ||
]); | ||
const result = await db.query(__1.sql ` | ||
const result = await db.query((0, __1.sql) ` | ||
SELECT * from dates_test_dates; | ||
@@ -344,3 +344,3 @@ `); | ||
]); | ||
expect(await db.query(__1.sql ` | ||
expect(await db.query((0, __1.sql) ` | ||
SELECT * from dates_test_pure_dates; | ||
@@ -369,4 +369,4 @@ `)).toEqual([ | ||
test('DATE as string', async () => { | ||
const db = __1.default({ dateMode: 'string' }); | ||
await db.query(__1.sql ` | ||
const db = (0, __1.default)({ dateMode: 'string' }); | ||
await db.query((0, __1.sql) ` | ||
DROP TABLE IF EXISTS dates_test_pure_dates; | ||
@@ -381,3 +381,3 @@ CREATE TABLE dates_test_pure_dates ( | ||
`); | ||
expect(await db.query(__1.sql `SELECT * from dates_test_pure_dates`)).toEqual([ | ||
expect(await db.query((0, __1.sql) `SELECT * from dates_test_pure_dates`)).toEqual([ | ||
{ | ||
@@ -395,4 +395,4 @@ date_value: '2000-06-03', | ||
test('DATE as utc', async () => { | ||
const db = __1.default({ timeZone: { client: 'utc' } }); | ||
await db.query(__1.sql ` | ||
const db = (0, __1.default)({ timeZone: { client: 'utc' } }); | ||
await db.query((0, __1.sql) ` | ||
DROP TABLE IF EXISTS dates_test_pure_dates; | ||
@@ -407,3 +407,3 @@ CREATE TABLE dates_test_pure_dates ( | ||
`); | ||
expect(await db.query(__1.sql `SELECT * from dates_test_pure_dates`)).toEqual([ | ||
expect(await db.query((0, __1.sql) `SELECT * from dates_test_pure_dates`)).toEqual([ | ||
{ | ||
@@ -410,0 +410,0 @@ date_value: new Date('2000-06-03T00:00:00.000Z'), |
@@ -5,3 +5,3 @@ "use strict"; | ||
jest.setTimeout(30000); | ||
const db = __1.default(); | ||
const db = (0, __1.default)(); | ||
afterAll(async () => { | ||
@@ -35,9 +35,9 @@ await db.dispose(); | ||
test('query', async () => { | ||
const [{ foo }] = await db.query(__1.sql `SELECT 1 + 1 as foo`); | ||
const [{ foo }] = await db.query((0, __1.sql) `SELECT 1 + 1 as foo`); | ||
expect(foo).toBe(2); | ||
}); | ||
test('query with params', async () => { | ||
const [{ foo }] = await db.query(__1.sql `SELECT 1 + ${41} as ${__1.sql.ident('foo')}`); | ||
const [{ foo }] = await db.query((0, __1.sql) `SELECT 1 + ${41} as ${__1.sql.ident('foo')}`); | ||
expect(foo).toBe(42); | ||
}); | ||
//# sourceMappingURL=index.test.mysql.js.map |
@@ -5,3 +5,3 @@ "use strict"; | ||
jest.setTimeout(30000); | ||
const db = __1.default(); | ||
const db = (0, __1.default)(); | ||
afterAll(async () => { | ||
@@ -12,3 +12,3 @@ await db.dispose(); | ||
beforeAll(async () => { | ||
await db.query(__1.sql `CREATE TABLE streaming_test_values (id BIGINT NOT NULL PRIMARY KEY);`); | ||
await db.query((0, __1.sql) `CREATE TABLE streaming_test_values (id BIGINT NOT NULL PRIMARY KEY);`); | ||
for (let batch = 0; batch < 10; batch++) { | ||
@@ -21,5 +21,5 @@ const batchValues = []; | ||
} | ||
await db.query(__1.sql ` | ||
await db.query((0, __1.sql) ` | ||
INSERT INTO streaming_test_values (id) | ||
VALUES ${__1.sql.join(batchValues.map((v) => __1.sql `(${v})`), __1.sql `,`)}; | ||
VALUES ${__1.sql.join(batchValues.map((v) => (0, __1.sql) `(${v})`), (0, __1.sql) `,`)}; | ||
`); | ||
@@ -31,3 +31,3 @@ } | ||
const results = []; | ||
db.queryNodeStream(__1.sql `SELECT * FROM streaming_test_values`, { | ||
db.queryNodeStream((0, __1.sql) `SELECT * FROM streaming_test_values`, { | ||
highWaterMark: 1, | ||
@@ -43,3 +43,3 @@ }) | ||
const results = []; | ||
for await (const { id } of db.queryStream(__1.sql `SELECT * FROM streaming_test_values`, { | ||
for await (const { id } of db.queryStream((0, __1.sql) `SELECT * FROM streaming_test_values`, { | ||
highWaterMark: 1, | ||
@@ -46,0 +46,0 @@ })) { |
@@ -22,3 +22,3 @@ "use strict"; | ||
openConnection: async (removeFromPool) => { | ||
const client = await promise_1.createConnection(srcConfig); | ||
const client = await (0, promise_1.createConnection)(srcConfig); | ||
const driver = new MySqlDriver_1.default(client, handlers, acquireLockTimeoutMilliseconds); | ||
@@ -25,0 +25,0 @@ try { |
@@ -10,3 +10,3 @@ "use strict"; | ||
const ConnectionPool_1 = require("./ConnectionPool"); | ||
const { connectionStringEnvironmentVariable } = mysql_config_1.getMySqlConfigSync(); | ||
const { connectionStringEnvironmentVariable } = (0, mysql_config_1.getMySqlConfigSync)(); | ||
function createConnectionPool(connectionConfig = process.env[connectionStringEnvironmentVariable]) { | ||
@@ -16,3 +16,3 @@ const connectionConfigObject = typeof connectionConfig === 'object' | ||
: { connectionString: connectionConfig }; | ||
const { connectionString = process.env[connectionStringEnvironmentVariable], } = connectionConfigObject; | ||
const { connectionString = process.env[connectionStringEnvironmentVariable] } = connectionConfigObject; | ||
if (!connectionString) { | ||
@@ -19,0 +19,0 @@ throw new Error('You must provide a connection string for @databases/mysql. You can ' + |
@@ -14,3 +14,2 @@ /// <reference types="node" /> | ||
private _endCalled; | ||
private readonly _disposed; | ||
constructor(client: MySqlClient, handlers: EventHandlers, acquireLockTimeoutMilliseconds: number); | ||
@@ -17,0 +16,0 @@ private _removeFromPool; |
@@ -9,3 +9,3 @@ "use strict"; | ||
const mysqlFormat = { | ||
escapeIdentifier: (str) => escape_identifier_1.escapeMySqlIdentifier(str), | ||
escapeIdentifier: (str) => (0, escape_identifier_1.escapeMySqlIdentifier)(str), | ||
formatValue: (value) => ({ placeholder: '?', value }), | ||
@@ -17,3 +17,3 @@ }; | ||
this._onIdleError = (err) => { | ||
if (this._disposed) { | ||
if (this._endCalled) { | ||
return; | ||
@@ -30,5 +30,2 @@ } | ||
this.acquireLockTimeoutMilliseconds = acquireLockTimeoutMilliseconds; | ||
this._disposed = new Promise((resolve) => { | ||
client.on('end', resolve); | ||
}); | ||
this.client = client; | ||
@@ -139,3 +136,3 @@ this._handlers = handlers; | ||
queryStream(query, options) { | ||
if (!sql_1.isSqlQuery(query)) { | ||
if (!(0, sql_1.isSqlQuery)(query)) { | ||
throw new Error('Invalid query, you must use @databases/sql to create your queries.'); | ||
@@ -146,3 +143,3 @@ } | ||
const connection = this.client.connection; | ||
return push_to_async_iterable_1.default((handlers) => { | ||
return (0, push_to_async_iterable_1.default)((handlers) => { | ||
const stream = connection.query(text, values); | ||
@@ -167,3 +164,3 @@ stream.on('result', handlers.onData); | ||
queryNodeStream(query, options) { | ||
if (!sql_1.isSqlQuery(query)) { | ||
if (!(0, sql_1.isSqlQuery)(query)) { | ||
throw new Error('Invalid query, you must use @databases/sql to create your queries.'); | ||
@@ -170,0 +167,0 @@ } |
{ | ||
"name": "@databases/mysql", | ||
"version": "5.1.0", | ||
"version": "5.1.1", | ||
"description": "", | ||
@@ -9,7 +9,7 @@ "main": "./lib/index.js", | ||
"@babel/code-frame": "^7.0.0", | ||
"@databases/escape-identifier": "^1.0.1", | ||
"@databases/mysql-config": "^2.0.0", | ||
"@databases/escape-identifier": "^1.0.2", | ||
"@databases/mysql-config": "^2.1.0", | ||
"@databases/push-to-async-iterable": "^3.0.0", | ||
"@databases/shared": "^3.0.0", | ||
"@databases/sql": "^3.0.0", | ||
"@databases/sql": "^3.2.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
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
141245
1475
+ Added@types/node@22.9.3(transitive)
- Removed@types/node@22.9.1(transitive)
Updated@databases/sql@^3.2.0