forked from ToolJet/ToolJet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpostgresql.test.js
More file actions
32 lines (27 loc) · 840 Bytes
/
postgresql.test.js
File metadata and controls
32 lines (27 loc) · 840 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
'use strict';
const postgresql = require('../lib');
describe('postgresql', () => {
it('should generate the query for bulk update operation', async () => {
const queryOptions = {
table: 'customers',
primary_key_column: 'id',
records: [
{
id: 1,
name: 'sam',
email: 'sam@example.com',
},
{
id: 2,
name: 'jon',
email: 'jon@example.com',
},
],
};
const _postgresql = new postgresql.default();
const builtQuery = await _postgresql.buildBulkUpdateQuery(queryOptions);
const expectedQuery =
"UPDATE customers SET name = 'sam', email = 'sam@example.com' WHERE id = 1; UPDATE customers SET name = 'jon', email = 'jon@example.com' WHERE id = 2;";
expect(builtQuery).toBe(expectedQuery);
});
});