Skip to content
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

Enable wrapIdentifier for SQLite .hasTable #4915

Merged
merged 10 commits into from Jan 10, 2022
3 changes: 3 additions & 0 deletions lib/execution/internal/query-executioner.js
Expand Up @@ -14,6 +14,9 @@ function formatQuery(sql, bindings, timeZone, client) {
return match;
}
const value = bindings[index++];
if (client.config.wrapIdentifier) {
return client.wrapIdentifier(value);
}
return client._escapeBinding(value, { timeZone });
});
}
Expand Down
15 changes: 15 additions & 0 deletions test/integration2/schema/misc.spec.js
Expand Up @@ -1576,6 +1576,21 @@ describe('Schema (misc)', () => {
knex.schema.hasTable('').then((resp) => {
expect(resp).to.equal(false);
}));

it('should not parse table name if wrapIdentifier is not specified', () => {
knex.schema.hasTable('testTableTwo').then((resp) => {
expect(resp).to.equal(false);
});
});

it('should parse table name if wrapIdentifier is specified', () => {
knex.client.config.wrapIdentifier = (value, origImpl, queryContext) =>
origImpl(_.snakeCase(value));

knex.schema.hasTable('testTableTwo').then((resp) => {
expect(resp).to.equal(true);
});
ramos-ph marked this conversation as resolved.
Show resolved Hide resolved
});
});

describe('renameTable', () => {
Expand Down