Skip to content

Commit b567d7d

Browse files
author
Kyle Farris
committed
Added update batch test to mssql test suite.
1 parent ba13b55 commit b567d7d

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

test/mssql/03-tests-update_batch.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const expect = require('chai').expect;
33
const QueryBuilder = require('../../drivers/mssql/query_builder.js');
44
const qb = new QueryBuilder();
55

6-
const test_where = {id:3};
6+
const test_where = {quadrant: 'Alpha'};
77
const test_data = [{id:3, name:'Milky Way', type: 'spiral'}, {id:4, name: 'Andromeda', type: 'spiral'}];
88

99
describe('MSSQL: update_batch()', () => {
@@ -18,4 +18,9 @@ describe('MSSQL: update_batch()', () => {
1818
const sql = qb.update_batch('galaxies', test_data, 'id');
1919
sql.should.eql(["UPDATE ([galaxies]) SET [name] = CASE WHEN [id] = 3 THEN 'Milky Way' WHEN [id] = 4 THEN 'Andromeda' ELSE [name] END, [type] = CASE WHEN [id] = 3 THEN 'spiral' WHEN [id] = 4 THEN 'spiral' ELSE [type] END WHERE [id] IN (3,4)"]);
2020
});
21+
it('should build a proper batch UPDATE string when where clause is provided', () => {
22+
qb.reset_query();
23+
const sql = qb.update_batch('galaxies', test_data, 'id', test_where);
24+
sql.should.eql(["UPDATE ([galaxies]) SET [name] = CASE WHEN [id] = 3 THEN 'Milky Way' WHEN [id] = 4 THEN 'Andromeda' ELSE [name] END, [type] = CASE WHEN [id] = 3 THEN 'spiral' WHEN [id] = 4 THEN 'spiral' ELSE [type] END WHERE [quadrant] = 'Alpha' AND [id] IN (3,4)"]);
25+
});
2126
});

0 commit comments

Comments
 (0)