knex/test/integration/query/deletes.js

87 lines
2.6 KiB
JavaScript
Raw Normal View History

'use strict';
2020-04-07 21:27:40 +02:00
const { TEST_TIMESTAMP } = require('../../util/constants');
2020-04-19 00:40:23 +02:00
module.exports = function (knex) {
describe('Deletes', function () {
it('should handle deletes', function () {
return knex('accounts')
.where('id', 1)
2014-04-16 02:50:19 -04:00
.del()
2020-04-19 00:40:23 +02:00
.testSql(function (tester) {
tester('mysql', 'delete from `accounts` where `id` = ?', [1], 1);
tester('pg', 'delete from "accounts" where "id" = ?', [1], 1);
Add redshift support without changing cli or package.json (#2233) * Add a Redshift dialect that inherits from Postgres. * Turn .index() and .dropIndex() into no-ops with warnings in the Redshift dialect. * Update the Redshift dialect to be compatible with master. * Update package.json * Disable liftoff cli * Remove the CLI * Add lib to the repo * Allow the escaping of named bindings. * Update dist * Update the Redshift dialect’s instantiation of the query and column compilers. * Update the distribution * Fix a merge conflict * Take lib back out * Trying to bring back in line with tgreisser/knex * Add npm 5 package-lock * Bring cli.js back in line * Bring cli.js back in line * Progress commit on redshift integration tests * Revert "Progress commit on redshift integration tests" This reverts commit 207e31635c638853dec54ce0580d34559ba5a54c. * Progress commit * Working not null on primary columns in createTable * Working redshift unit tests * Working unit and integration tests, still need to fix migration tests * Brought datatypes more in line with what redshift actually supports * Added query compiler unit tests * Add a hacky returning clause for redshift ugh * Working migration integration tests * Working insert integration tests * Allow multiple insert returning values * Working select integration tests * Working join integration tests * Working aggregate integration tests * All integration suite tests working * Put docker index for reconnect tests back * Redshift does not support insert...returning, there does not seem to be a way around that, therefore accept it and test accordingly * Leave redshift integration tests in place, but do not run them by default * Fix mysql order by test * Fix more tests * Change test db name to knex_test for consistency * Address PR comments
2018-02-03 08:33:02 -05:00
tester(
'pg-redshift',
'delete from "accounts" where "id" = ?',
[1],
1
);
tester('sqlite3', 'delete from `accounts` where `id` = ?', [1], 1);
tester('oracledb', 'delete from "accounts" where "id" = ?', [1], 1);
tester(
'mssql',
'delete from [accounts] where [id] = ?;select @@rowcount',
[1],
1
);
2014-04-16 02:50:19 -04:00
});
});
2020-04-19 00:40:23 +02:00
it('should allow returning for deletes in postgresql and mssql', function () {
return knex('accounts')
.where('id', 2)
2014-04-16 02:50:19 -04:00
.del('*')
2020-04-19 00:40:23 +02:00
.testSql(function (tester) {
tester('mysql', 'delete from `accounts` where `id` = ?', [2], 1);
2014-04-16 02:59:27 -04:00
tester(
'pg',
2014-04-16 02:59:27 -04:00
'delete from "accounts" where "id" = ? returning *',
[2],
[
{
id: '2',
first_name: 'Test',
last_name: 'User',
email: 'test2@example.com',
logins: 1,
balance: 0,
about: 'Lorem ipsum Dolore labore incididunt enim.',
created_at: TEST_TIMESTAMP,
updated_at: TEST_TIMESTAMP,
phone: null,
},
]
2014-04-16 02:59:27 -04:00
);
Add redshift support without changing cli or package.json (#2233) * Add a Redshift dialect that inherits from Postgres. * Turn .index() and .dropIndex() into no-ops with warnings in the Redshift dialect. * Update the Redshift dialect to be compatible with master. * Update package.json * Disable liftoff cli * Remove the CLI * Add lib to the repo * Allow the escaping of named bindings. * Update dist * Update the Redshift dialect’s instantiation of the query and column compilers. * Update the distribution * Fix a merge conflict * Take lib back out * Trying to bring back in line with tgreisser/knex * Add npm 5 package-lock * Bring cli.js back in line * Bring cli.js back in line * Progress commit on redshift integration tests * Revert "Progress commit on redshift integration tests" This reverts commit 207e31635c638853dec54ce0580d34559ba5a54c. * Progress commit * Working not null on primary columns in createTable * Working redshift unit tests * Working unit and integration tests, still need to fix migration tests * Brought datatypes more in line with what redshift actually supports * Added query compiler unit tests * Add a hacky returning clause for redshift ugh * Working migration integration tests * Working insert integration tests * Allow multiple insert returning values * Working select integration tests * Working join integration tests * Working aggregate integration tests * All integration suite tests working * Put docker index for reconnect tests back * Redshift does not support insert...returning, there does not seem to be a way around that, therefore accept it and test accordingly * Leave redshift integration tests in place, but do not run them by default * Fix mysql order by test * Fix more tests * Change test db name to knex_test for consistency * Address PR comments
2018-02-03 08:33:02 -05:00
tester(
'pg-redshift',
'delete from "accounts" where "id" = ?',
[2],
1
);
tester('sqlite3', 'delete from `accounts` where `id` = ?', [2], 1);
tester('oracledb', 'delete from "accounts" where "id" = ?', [2], 1);
tester(
'mssql',
'delete from [accounts] output deleted.* where [id] = ?',
[2],
[
{
id: '2',
first_name: 'Test',
last_name: 'User',
email: 'test2@example.com',
logins: 1,
balance: 0,
about: 'Lorem ipsum Dolore labore incididunt enim.',
created_at: TEST_TIMESTAMP,
updated_at: TEST_TIMESTAMP,
phone: null,
},
]
);
2014-04-16 02:50:19 -04:00
});
});
});
};