-
Notifications
You must be signed in to change notification settings - Fork 1
feat: use sql params #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -13,7 +13,7 @@ export interface RDSClientOptions extends PoolOptions { | |||||
| } | ||||||
|
|
||||||
| export interface PoolConnectionPromisify extends Omit<PoolConnection, 'query'> { | ||||||
| query(sql: string): Promise<any>; | ||||||
| query(sql: string, values: any | any[] | { [param: string]: any }): Promise<any>; | ||||||
|
||||||
| query(sql: string, values: any | any[] | { [param: string]: any }): Promise<any>; | |
| query(sql: string, values?: any | any[] | { [param: string]: any }): Promise<any>; |
🤖 Prompt for AI Agents
In src/types.ts around line 16, the query signature currently requires the
values parameter which is inconsistent with implementations; change the
signature to make values optional (e.g., values?: any) to restore compatibility
and simplify the type (use any instead of the union of array/object/any). Ensure
the exported type/signature is updated so callers and implementations that omit
values no longer error on typing.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -357,7 +357,7 @@ describe('test/client.test.ts', () => { | |
| [ table, prefix + '[email protected]' ]); | ||
| assert.deepEqual(mockLogs, [ | ||
| 'show tables', | ||
| `select * from \`${table}\` where email = '${prefix + '[email protected]'}' limit 1`, | ||
| 'select * from ?? where email = ? limit 1', | ||
| ]); | ||
| }); | ||
| }); | ||
|
|
@@ -1478,7 +1478,7 @@ describe('test/client.test.ts', () => { | |
| counter2After++; | ||
| }); | ||
| await db.query('select * from ?? limit 10', [ table ]); | ||
| assert.equal(lastSql, 'select * from `myrds-test-user` limit 10'); | ||
| assert.equal(lastSql, 'select * from ?? limit 10'); | ||
| assert.equal(lastArgs[0], lastSql); | ||
| assert.equal(Array.isArray(lastArgs[1]), true); | ||
| assert.equal(count, 1); | ||
|
|
@@ -1491,8 +1491,8 @@ describe('test/client.test.ts', () => { | |
| values(?, ?, now(), now())`, | ||
| [ table, prefix + 'beginTransactionScope1', prefix + '[email protected]' ]); | ||
| }); | ||
| assert.equal(lastSql, 'insert into `myrds-test-user`(name, email, gmt_create, gmt_modified)\n' + | ||
| ` values('${prefix}beginTransactionScope1', '${prefix}[email protected]', now(), now())`); | ||
| assert.equal(lastSql, 'insert into ??(name, email, gmt_create, gmt_modified)\n' + | ||
| ' values(?, ?, now(), now())'); | ||
| assert.equal(lastArgs[0], lastSql); | ||
| assert.equal(lastArgs[1].affectedRows, 1); | ||
| assert.equal(count, 2); | ||
|
|
@@ -1502,8 +1502,8 @@ describe('test/client.test.ts', () => { | |
| values(?, ?, now(), now())`, | ||
| [ table, prefix + 'beginDoomedTransactionScope1', prefix + '[email protected]' ]); | ||
| }); | ||
| assert.equal(lastSql, 'insert into `myrds-test-user`(name, email, gmt_create, gmt_modified)\n' + | ||
| ` values('${prefix}beginDoomedTransactionScope1', '${prefix}[email protected]', now(), now())`); | ||
| assert.equal(lastSql, 'insert into ??(name, email, gmt_create, gmt_modified)\n' + | ||
| ' values(?, ?, now(), now())'); | ||
| assert.equal(lastArgs[0], lastSql); | ||
| assert.equal(lastArgs[1].affectedRows, 1); | ||
| assert.equal(count, 3); | ||
|
|
@@ -1514,8 +1514,8 @@ describe('test/client.test.ts', () => { | |
| values(?, ?, now(), now())`, | ||
| [ table, prefix + 'transaction1', prefix + '[email protected]' ]); | ||
| await conn.commit(); | ||
| assert.equal(lastSql, 'insert into `myrds-test-user`(name, email, gmt_create, gmt_modified)\n' + | ||
| ` values('${prefix}transaction1', '${prefix}[email protected]', now(), now())`); | ||
| assert.equal(lastSql, 'insert into ??(name, email, gmt_create, gmt_modified)\n' + | ||
| ' values(?, ?, now(), now())'); | ||
| assert.equal(lastArgs[0], lastSql); | ||
| assert.equal(lastArgs[1].affectedRows, 1); | ||
| assert.equal(count, 4); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.