mirror of
https://github.com/ToolJet/ToolJet
synced 2026-04-21 21:47:17 +00:00
32 lines
840 B
JavaScript
32 lines
840 B
JavaScript
'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: '[email protected]',
|
|
},
|
|
{
|
|
id: 2,
|
|
name: 'jon',
|
|
email: '[email protected]',
|
|
},
|
|
],
|
|
};
|
|
|
|
const _postgresql = new postgresql.default();
|
|
|
|
const builtQuery = await _postgresql.buildBulkUpdateQuery(queryOptions);
|
|
const expectedQuery =
|
|
"UPDATE customers SET name = 'sam', email = '[email protected]' WHERE id = 1; UPDATE customers SET name = 'jon', email = '[email protected]' WHERE id = 2;";
|
|
|
|
expect(builtQuery).toBe(expectedQuery);
|
|
});
|
|
});
|