mirror of
https://github.com/mariadb-corporation/mariadb-connector-nodejs.git
synced 2025-07-29 11:59:44 +00:00
[CONJS-199] return type for batch() is wrong on typescript
This commit is contained in:
6
types/index.d.ts
vendored
6
types/index.d.ts
vendored
@ -576,7 +576,7 @@ export interface Connection {
|
||||
/**
|
||||
* Execute batch. Values are Array of Array.
|
||||
*/
|
||||
batch(sql: string | QueryOptions, values?: any): Promise<UpsertResult[]>;
|
||||
batch(sql: string | QueryOptions, values?: any): Promise<UpsertResult> | Promise<UpsertResult[]>;
|
||||
|
||||
/**
|
||||
* Execute query returning a Readable Object that will emit columns/data/end/error events
|
||||
@ -678,7 +678,7 @@ export interface Pool {
|
||||
/**
|
||||
* Execute a batch on one connection from pool.
|
||||
*/
|
||||
batch(sql: string | QueryOptions, values?: any): Promise<UpsertResult[]>;
|
||||
batch(sql: string | QueryOptions, values?: any): Promise<UpsertResult> | Promise<UpsertResult[]>;
|
||||
|
||||
/**
|
||||
* Execute query using binary (prepare) protocol
|
||||
@ -737,7 +737,7 @@ export interface Pool {
|
||||
export interface FilteredPoolCluster {
|
||||
getConnection(): Promise<PoolConnection>;
|
||||
query(sql: string | QueryOptions, values?: any): Promise<any>;
|
||||
batch(sql: string | QueryOptions, values?: any): Promise<UpsertResult[]>;
|
||||
batch(sql: string | QueryOptions, values?: any): Promise<UpsertResult> | Promise<UpsertResult[]>;
|
||||
execute(sql: string | QueryOptions, values?: any): Promise<any>;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import mariadb = require('..');
|
||||
import { Connection, FieldInfo, ConnectionConfig, PoolConfig } from '..';
|
||||
import { Connection, FieldInfo, ConnectionConfig, PoolConfig, UpsertResult } from '..';
|
||||
import { Stream } from 'stream';
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
@ -150,7 +150,11 @@ async function testMisc(): Promise<void> {
|
||||
connection.escape(true);
|
||||
connection.escape(5);
|
||||
connection.escapeId('myColumn');
|
||||
|
||||
const res = (await connection.batch('INSERT INTO myTable VALUE (?,?)', [
|
||||
[1, 2],
|
||||
[4, 3]
|
||||
])) as UpsertResult;
|
||||
console.log(res.affectedRows);
|
||||
await createConnection({ multipleStatements: true });
|
||||
|
||||
await createConnection({ debug: true });
|
||||
@ -221,7 +225,11 @@ async function testPool(): Promise<void> {
|
||||
pool.escape(true);
|
||||
pool.escape(5);
|
||||
pool.escapeId('myColumn');
|
||||
|
||||
const res = (await pool.batch('INSERT INTO myTable VALUE (?,?)', [
|
||||
[1, 2],
|
||||
[4, 3]
|
||||
])) as UpsertResult;
|
||||
console.log(res.affectedRows);
|
||||
console.log(connection.threadId != null);
|
||||
|
||||
await connection.query('SELECT 1 + 1 AS solution');
|
||||
@ -258,8 +266,15 @@ async function testPoolCluster(): Promise<void> {
|
||||
connection = await poolCluster.of(null, 'RR').getConnection();
|
||||
console.log(connection.threadId != null);
|
||||
|
||||
poolCluster.of('SLAVE.*', 'RANDOM');
|
||||
const filtered = poolCluster.of('SLAVE.*', 'RANDOM');
|
||||
const res = (await filtered.batch('INSERT INTO myTable VALUE (?,?)', [
|
||||
[1, 2],
|
||||
[4, 3]
|
||||
])) as UpsertResult;
|
||||
console.log(res.affectedRows);
|
||||
|
||||
await filtered.query('SELECT 1 + 1 AS solution');
|
||||
connection.release();
|
||||
mariadb.createPoolCluster({
|
||||
canRetry: true,
|
||||
removeNodeErrorCount: 3,
|
||||
|
Reference in New Issue
Block a user