mirror of
https://github.com/knex/knex.git
synced 2025-08-03 14:22:01 +00:00

* `chai` is no longer global * sinon is no longer globally defined * expect(..) is no longer defined globally * Removed obsolete eslint hints about globals * Removed unused variable ( `expect(..)` )
34 lines
938 B
JavaScript
34 lines
938 B
JavaScript
'use strict';
|
|
const expect = require('chai').expect;
|
|
const knex = require('../../../knex');
|
|
|
|
describe('MSSQL unit tests', () => {
|
|
const knexInstance = knex({
|
|
client: 'mssql',
|
|
connection: {
|
|
port: 1433,
|
|
host: '127.0.0.1',
|
|
password: 'yourStrong(!)Password',
|
|
user: 'sa',
|
|
},
|
|
});
|
|
|
|
it('should escape statements with [] correctly', async () => {
|
|
const sql = knexInstance('projects')
|
|
.where('id] = 1 UNION SELECT 1, @@version -- --', 1)
|
|
.toSQL();
|
|
expect(sql.sql).to.equal(
|
|
'select * from [projects] where [id = 1 UNION SELECT 1, @@version -- --] = ?'
|
|
);
|
|
});
|
|
|
|
it('should escape statements with "" correctly', async () => {
|
|
const sql = knexInstance('projects')
|
|
.where('id]" = 1 UNION SELECT 1, @@version -- --', 1)
|
|
.toSQL();
|
|
expect(sql.sql).to.equal(
|
|
'select * from [projects] where [id" = 1 UNION SELECT 1, @@version -- --] = ?'
|
|
);
|
|
});
|
|
});
|