2014-09-01 17:19:34 +02:00

86 lines
1.9 KiB
JavaScript

/*global describe, d, it*/
'use strict';
module.exports = function(knex) {
describe('Deletes', function () {
it('should handle deletes', function() {
return knex('accounts')
.where('id', 1)
.del()
.testSql(function(tester) {
tester(
'mysql',
'delete from `accounts` where `id` = ?',
[1],
1
);
tester(
'postgresql',
'delete from "accounts" where "id" = ?',
[1],
1
);
tester(
'sqlite3',
'delete from "accounts" where "id" = ?',
[1],
1
);
tester(
'oracle',
'delete from "accounts" where "id" = ?',
[1],
1
);
});
});
it('should allow returning for deletes in postgresql', function() {
return knex('accounts')
.where('id', 2)
.del('*')
.testSql(function(tester) {
tester(
'mysql',
'delete from `accounts` where `id` = ?',
[2],
1
);
tester(
'postgresql',
'delete from "accounts" where "id" = ? returning *',
[2],
[{
id: '2',
first_name: 'Test',
last_name: 'User',
email: 'test2@example.com',
logins: 1,
about: 'Lorem ipsum Dolore labore incididunt enim.',
created_at: d,
updated_at: d,
phone: null
}]
);
tester(
'sqlite3',
'delete from "accounts" where "id" = ?',
[2],
1
);
tester(
'oracle',
'delete from "accounts" where "id" = ?',
[2],
1
);
});
});
});
};