-
-
Notifications
You must be signed in to change notification settings - Fork 628
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2053 from wellwelwel/release-connection
fix: releaseConnection types and promise
- Loading branch information
Showing
17 changed files
with
187 additions
and
7 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
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,15 @@ | ||
import { mysql } from '../../../index'; | ||
import { access } from '../../baseConnection'; | ||
|
||
const pool = mysql.createPool(access); | ||
|
||
pool.getConnection((err, conn) => { | ||
conn.connection; | ||
|
||
try { | ||
// @ts-expect-error: The pool can't be a connection itself | ||
pool.connection; | ||
} catch (err) { | ||
console.log('This error is expected', err); | ||
} | ||
}); |
13 changes: 13 additions & 0 deletions
13
test/tsc-build/mysql/createPool/callbacks/getConnection.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,13 @@ | ||
import { mysql } from '../../../index'; | ||
import { access } from '../../baseConnection'; | ||
|
||
const pool = mysql.createPool(access); | ||
|
||
pool.getConnection((err, conn) => { | ||
try { | ||
// @ts-expect-error: The connection can't get another connection | ||
conn.getConnection(); | ||
} catch (err) { | ||
console.log('This error is expected', err); | ||
} | ||
}); |
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,15 @@ | ||
import { mysql } from '../../../index'; | ||
import { access } from '../../baseConnection'; | ||
|
||
const pool = mysql.createPool(access); | ||
|
||
pool.getConnection((err, conn) => { | ||
conn.release(); | ||
|
||
try { | ||
// @ts-expect-error: The pool isn't a connection itself, so it doesn't have the connection methods | ||
pool.release(); | ||
} catch (err) { | ||
console.log('This error is expected', err); | ||
} | ||
}); |
8 changes: 8 additions & 0 deletions
8
test/tsc-build/mysql/createPool/callbacks/releaseConnection.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,8 @@ | ||
import { mysql } from '../../../index'; | ||
import { access } from '../../baseConnection'; | ||
|
||
const pool = mysql.createPool(access); | ||
|
||
pool.getConnection((err, conn) => { | ||
pool.releaseConnection(conn); | ||
}); |
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,16 @@ | ||
import { mysql } from '../../../index'; | ||
import { access } from '../../baseConnection'; | ||
|
||
(async () => { | ||
const pool = mysql.createPool(access); | ||
const conn = await pool.promise().getConnection(); | ||
|
||
conn.connection; | ||
|
||
try { | ||
// @ts-expect-error: The pool can't be a connection itself | ||
pool.connection; | ||
} catch (err) { | ||
console.log('This error is expected', err); | ||
} | ||
})(); |
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,14 @@ | ||
import { mysql } from '../../../index'; | ||
import { access } from '../../baseConnection'; | ||
|
||
(async () => { | ||
const pool = mysql.createPool(access); | ||
const conn = await pool.promise().getConnection(); | ||
|
||
try { | ||
// @ts-expect-error: The connection can't get another connection | ||
conn.getConnection(); | ||
} catch (err) { | ||
console.log('This error is expected', err); | ||
} | ||
})(); |
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,16 @@ | ||
import { mysql } from '../../../index'; | ||
import { access } from '../../baseConnection'; | ||
|
||
(async () => { | ||
const pool = mysql.createPool(access); | ||
const conn = await pool.promise().getConnection(); | ||
|
||
conn.release(); | ||
|
||
try { | ||
// @ts-expect-error: The pool isn't a connection itself, so it doesn't have the connection methods | ||
pool.release(); | ||
} catch (err) { | ||
console.log('This error is expected', err); | ||
} | ||
})(); |
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,9 @@ | ||
import { mysql } from '../../../index'; | ||
import { access } from '../../baseConnection'; | ||
|
||
(async () => { | ||
const pool = mysql.createPool(access); | ||
const conn = await pool.promise().getConnection(); | ||
|
||
pool.releaseConnection(conn); | ||
})(); |
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,16 @@ | ||
import { mysqlp as mysql } from '../../index'; | ||
import { access } from '../baseConnection'; | ||
|
||
(async () => { | ||
const pool = mysql.createPool(access); | ||
const conn = await pool.getConnection(); | ||
|
||
conn.connection; | ||
|
||
try { | ||
// @ts-expect-error: The pool can't be a connection itself | ||
pool.connection; | ||
} catch (err) { | ||
console.log('This error is expected', err); | ||
} | ||
})(); |
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,16 @@ | ||
import { mysqlp as mysql } from '../../index'; | ||
import { access } from '../baseConnection'; | ||
|
||
(async () => { | ||
const pool = mysql.createPool(access); | ||
const conn = await pool.getConnection(); | ||
|
||
conn.connection; | ||
|
||
try { | ||
// @ts-expect-error: The connection can't get another connection | ||
conn.getConnection(); | ||
} catch (err) { | ||
console.log('This error is expected', err); | ||
} | ||
})(); |
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,16 @@ | ||
import { mysqlp as mysql } from '../../index'; | ||
import { access } from '../baseConnection'; | ||
|
||
(async () => { | ||
const pool = mysql.createPool(access); | ||
const conn = await pool.getConnection(); | ||
|
||
conn.release(); | ||
|
||
try { | ||
// @ts-expect-error: The pool isn't a connection itself, so it doesn't have the connection methods | ||
pool.release(); | ||
} catch (err) { | ||
console.log('This error is expected', err); | ||
} | ||
})(); |
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,9 @@ | ||
import { mysqlp as mysql } from '../../index'; | ||
import { access } from '../baseConnection'; | ||
|
||
(async () => { | ||
const pool = mysql.createPool(access); | ||
const conn = await pool.getConnection(); | ||
|
||
pool.releaseConnection(conn); | ||
})(); |
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