forked from sidorares/node-mysql2
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Missing types in "mysql" import (sidorares#1995)
* fix: `execute` types in `Connection` * fix: `promise` options don't appears * fix: missing `execute` method in `Pool` * fix: missing `getConnection()` in `.promise()` * fix: patterning `execute` overloads in mysql import * fix: `promise` method types in `createConnection` * fix: `promise` method types in `createPool` * add: TypeScript build tests for mysql `createPool` and `createConnection` * add: TypeScript build tests for mysql/promise `createPool` and `createConnection` * add: description for further contributions in TypeScript build tests * fix: call methods in createConnection tsc-build
- Loading branch information
1 parent
0bf4df2
commit b8c79d0
Showing
21 changed files
with
715 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { mysql } from '../index'; | ||
|
||
export const access: mysql.ConnectionOptions = { | ||
host: '', | ||
user: '', | ||
password: '', | ||
database: '', | ||
}; | ||
|
||
/** The SQL for the query */ | ||
export const sql = 'SELECT * FROM `table`'; | ||
|
||
/** The SQL for the query with prepared statements */ | ||
export const sqlPS = 'SELECT * FROM `table` WHERE `id` = ?'; | ||
|
||
/** The values for the query with prepared statements */ | ||
export const values = [1]; |
31 changes: 31 additions & 0 deletions
31
test/tsc-build/mysql/createConnection/callbacks/execute.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { mysql } from '../../../index'; | ||
import { access, sql, sqlPS, values } from '../../baseConnection'; | ||
|
||
{ | ||
const db = mysql.createConnection(access); | ||
|
||
/** Overload: execute(sql, () => {}}) */ | ||
db.execute(sql, (err, result, fields) => { | ||
console.log(err, result, fields); | ||
}); | ||
|
||
/** Overload: execute(sql, values, () => {}}) */ | ||
db.execute(sqlPS, values, (err, result, fields) => { | ||
console.log(err, result, fields); | ||
}); | ||
|
||
/** Overload: execute(QueryOptions, () => {}}) I */ | ||
db.execute({ sql }, (err, result, fields) => { | ||
console.log(err, result, fields); | ||
}); | ||
|
||
/** Overload: execute(QueryOptions, () => {}}) II */ | ||
db.execute({ sql: sqlPS, values }, (err, result, fields) => { | ||
console.log(err, result, fields); | ||
}); | ||
|
||
/** Overload: execute(QueryOptions, values, () => {}}) */ | ||
db.execute({ sql: sqlPS }, values, (err, result, fields) => { | ||
console.log(err, result, fields); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { mysql } from '../../../index'; | ||
import { access, sql, sqlPS, values } from '../../baseConnection'; | ||
|
||
{ | ||
const db = mysql.createConnection(access); | ||
|
||
/** Overload: query(sql, () => {}}) */ | ||
db.query(sql, (err, result, fields) => { | ||
console.log(err, result, fields); | ||
}); | ||
|
||
/** Overload: query(sql, values, () => {}}) */ | ||
db.query(sqlPS, values, (err, result, fields) => { | ||
console.log(err, result, fields); | ||
}); | ||
|
||
/** Overload: query(QueryOptions, () => {}}) I */ | ||
db.query({ sql }, (err, result, fields) => { | ||
console.log(err, result, fields); | ||
}); | ||
|
||
/** Overload: query(QueryOptions, () => {}}) II */ | ||
db.query({ sql: sqlPS, values }, (err, result, fields) => { | ||
console.log(err, result, fields); | ||
}); | ||
|
||
/** Overload: query(QueryOptions, values, () => {}}) */ | ||
db.query({ sql: sqlPS }, values, (err, result, fields) => { | ||
console.log(err, result, fields); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { mysql } from '../../../index'; | ||
import { access, sql, sqlPS, values } from '../../baseConnection'; | ||
|
||
(async () => { | ||
const db = mysql.createConnection(access).promise(); | ||
|
||
{ | ||
/** Overload: execute(sql) */ | ||
const [results, fields] = await db.execute(sql); | ||
console.log(results, fields); | ||
} | ||
|
||
{ | ||
/** Overload: execute(sql, values) */ | ||
const [results, fields] = await db.execute(sqlPS, values); | ||
console.log(results, fields); | ||
} | ||
|
||
{ | ||
/** Overload: execute(QueryOptions) I */ | ||
const [results, fields] = await db.execute({ sql }); | ||
console.log(results, fields); | ||
} | ||
|
||
{ | ||
/** Overload: execute(QueryOptions) II */ | ||
const [results, fields] = await db.execute({ sql: sqlPS, values }); | ||
console.log(results, fields); | ||
} | ||
|
||
{ | ||
/** Overload: execute(QueryOptions, values) */ | ||
const [results, fields] = await db.execute({ sql: sqlPS }, values); | ||
console.log(results, fields); | ||
} | ||
|
||
await db.end(); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { mysql } from '../../../index'; | ||
import { access, sql, sqlPS, values } from '../../baseConnection'; | ||
|
||
(async () => { | ||
const db = mysql.createConnection(access).promise(); | ||
|
||
{ | ||
/** Overload: query(sql) */ | ||
const [results, fields] = await db.query(sql); | ||
console.log(results, fields); | ||
} | ||
|
||
{ | ||
/** Overload: query(sql, values) */ | ||
const [results, fields] = await db.query(sqlPS, values); | ||
console.log(results, fields); | ||
} | ||
|
||
{ | ||
/** Overload: query(QueryOptions) I */ | ||
const [results, fields] = await db.query({ sql }); | ||
console.log(results, fields); | ||
} | ||
|
||
{ | ||
/** Overload: query(QueryOptions) II */ | ||
const [results, fields] = await db.query({ sql: sqlPS, values }); | ||
console.log(results, fields); | ||
} | ||
|
||
{ | ||
/** Overload: query(QueryOptions, values) */ | ||
const [results, fields] = await db.query({ sql: sqlPS }, values); | ||
console.log(results, fields); | ||
} | ||
|
||
await db.end(); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { mysql } from '../../../index'; | ||
import { access, sql, sqlPS, values } from '../../baseConnection'; | ||
|
||
{ | ||
const db = mysql.createPool(access); | ||
|
||
/** Overload: execute(sql, () => {}}) */ | ||
db.execute(sql, (err, result, fields) => { | ||
console.log(err, result, fields); | ||
}); | ||
|
||
/** Overload: execute(sql, values, () => {}}) */ | ||
db.execute(sqlPS, values, (err, result, fields) => { | ||
console.log(err, result, fields); | ||
}); | ||
|
||
/** Overload: execute(QueryOptions, () => {}}) I */ | ||
db.execute({ sql }, (err, result, fields) => { | ||
console.log(err, result, fields); | ||
}); | ||
|
||
/** Overload: execute(QueryOptions, () => {}}) II */ | ||
db.execute({ sql: sqlPS, values }, (err, result, fields) => { | ||
console.log(err, result, fields); | ||
}); | ||
|
||
/** Overload: execute(QueryOptions, values, () => {}}) */ | ||
db.execute({ sql: sqlPS }, values, (err, result, fields) => { | ||
console.log(err, result, fields); | ||
}); | ||
} | ||
|
||
/** getConnection and query */ | ||
{ | ||
mysql.createPool(access).getConnection((err, connection) => { | ||
/** Overload: execute(sql, () => {}}) */ | ||
connection.execute(sql, (err, result, fields) => { | ||
console.log(err, result, fields); | ||
}); | ||
|
||
/** Overload: execute(sql, values, () => {}}) */ | ||
connection.execute(sqlPS, values, (err, result, fields) => { | ||
console.log(err, result, fields); | ||
}); | ||
|
||
/** Overload: execute(QueryOptions, () => {}}) I */ | ||
connection.execute({ sql }, (err, result, fields) => { | ||
console.log(err, result, fields); | ||
}); | ||
|
||
/** Overload: execute(QueryOptions, () => {}}) II */ | ||
connection.execute({ sql: sqlPS, values }, (err, result, fields) => { | ||
console.log(err, result, fields); | ||
}); | ||
|
||
/** Overload: execute(QueryOptions, values, () => {}}) */ | ||
connection.execute({ sql: sqlPS }, values, (err, result, fields) => { | ||
console.log(err, result, fields); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { mysql } from '../../../index'; | ||
import { access, sql, sqlPS, values } from '../../baseConnection'; | ||
|
||
{ | ||
const db = mysql.createPool(access); | ||
|
||
/** Overload: query(sql, () => {}}) */ | ||
db.query(sql, (err, result, fields) => { | ||
console.log(err, result, fields); | ||
}); | ||
|
||
/** Overload: query(sql, values, () => {}}) */ | ||
db.query(sqlPS, values, (err, result, fields) => { | ||
console.log(err, result, fields); | ||
}); | ||
|
||
/** Overload: query(QueryOptions, () => {}}) I */ | ||
db.query({ sql }, (err, result, fields) => { | ||
console.log(err, result, fields); | ||
}); | ||
|
||
/** Overload: query(QueryOptions, () => {}}) II */ | ||
db.query({ sql: sqlPS, values }, (err, result, fields) => { | ||
console.log(err, result, fields); | ||
}); | ||
|
||
/** Overload: query(QueryOptions, values, () => {}}) */ | ||
db.query({ sql: sqlPS }, values, (err, result, fields) => { | ||
console.log(err, result, fields); | ||
}); | ||
} | ||
|
||
/** getConnection */ | ||
{ | ||
mysql.createPool(access).getConnection((err, connection) => { | ||
/** Overload: query(sql, () => {}}) */ | ||
connection.query(sql, (err, result, fields) => { | ||
console.log(err, result, fields); | ||
}); | ||
|
||
/** Overload: query(sql, values, () => {}}) */ | ||
connection.query(sqlPS, values, (err, result, fields) => { | ||
console.log(err, result, fields); | ||
}); | ||
|
||
/** Overload: query(QueryOptions, () => {}}) I */ | ||
connection.query({ sql }, (err, result, fields) => { | ||
console.log(err, result, fields); | ||
}); | ||
|
||
/** Overload: query(QueryOptions, () => {}}) II */ | ||
connection.query({ sql: sqlPS, values }, (err, result, fields) => { | ||
console.log(err, result, fields); | ||
}); | ||
|
||
/** Overload: query(QueryOptions, values, () => {}}) */ | ||
connection.query({ sql: sqlPS }, values, (err, result, fields) => { | ||
console.log(err, result, fields); | ||
}); | ||
}); | ||
} |
Oops, something went wrong.