Skip to content

Commit

Permalink
Fix #129 - Fix schemas option in MSSQL.
Browse files Browse the repository at this point in the history
  • Loading branch information
rmp135 committed May 25, 2023
1 parent ccf8f16 commit fc12c6e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/Adapters/mssql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ export default class implements AdapterInterface {
UNION
SELECT TOP 1 value FROM fn_listextendedproperty (NULL, 'schema', TABLE_SCHEMA, 'view', TABLE_NAME, null, null) EP WHERE EP.name = 'MS_Description'
) EP
${schemas.length > 0 ? `WHERE TABLE_SCHEMA IN (:schemas)` : ''}`
return await db.raw(sql, { schemas })
${schemas.length > 0 ? `WHERE TABLE_SCHEMA IN (${schemas.map(_ => '?').join(',')})` : ''}`
return await db.raw(sql, schemas)
}

async getAllColumns(db: Knex, config: Config, table: string, schema: string): Promise<ColumnDefinition[]> {
Expand Down
4 changes: 2 additions & 2 deletions src/specs/Adapters/mssql.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ describe('mssql', () => {
const mockdb = { raw: mockRaw }
const adapter = new Mockmssql.default()
const res = await adapter.getAllTables(mockdb as any, ['schema1', 'schema2'])
expect(mockRaw.calls.first().args[0]).toContain('WHERE TABLE_SCHEMA IN (:schemas)')
expect(mockRaw.calls.first().args[1]).toEqual({ schemas: ['schema1', 'schema2'] })
expect(mockRaw.calls.first().args[0]).toContain('WHERE TABLE_SCHEMA IN (?,?)')
expect(mockRaw.calls.first().args[1]).toEqual(['schema1', 'schema2'])
expect(res).toEqual(mockRawReturn as any)
})
})
Expand Down

0 comments on commit fc12c6e

Please sign in to comment.