Skip to content

Commit

Permalink
Update JoinRaw bindings type to accept arrays (#4752)
Browse files Browse the repository at this point in the history
  • Loading branch information
RyWilliams committed Oct 20, 2021
1 parent 60db2d2 commit 3e53c03
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 12 additions & 1 deletion test-tsd/select.test-d.ts
@@ -1,5 +1,5 @@
import Knex from '../types';
import { clientConfig, User } from './common';
import { clientConfig, User, Department } from './common';
import { expectType } from 'tsd';

const knex = Knex(clientConfig);
Expand Down Expand Up @@ -67,6 +67,17 @@ const main = async () => {
await knex<User>('users').select('id', 'age')
);

expectType<User[]>(
await knex<User>('users').joinRaw(
`JOIN (
SELECT id
FROM departments
WHERE departments.departmentName = ANY(?)
) AS d ON d.id = users.id`,
[['Name 1, Name 2']]
)
);

knex.transaction(async trx => {
expectType<User[]>(await trx.select('*').from('users'));
});
Expand Down
2 changes: 1 addition & 1 deletion types/index.d.ts
Expand Up @@ -1259,7 +1259,7 @@ export declare namespace Knex {
}

interface JoinRaw<TRecord = any, TResult = unknown[]> {
(tableName: string, binding?: Value | ValueDict): QueryBuilder<
(tableName: string, binding?: Value | Value[] | ValueDict): QueryBuilder<
TRecord,
TResult
>;
Expand Down

0 comments on commit 3e53c03

Please sign in to comment.