86 lines
1.9 KiB
JavaScript
Raw Normal View History

/*global describe, d, it*/
'use strict';
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()
.testSql(function(tester) {
2014-04-16 02:59:27 -04:00
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
);
2014-04-16 02:50:19 -04:00
});
});
it('should allow returning for deletes in postgresql', function() {
return knex('accounts')
.where('id', 2)
2014-04-16 02:50:19 -04:00
.del('*')
.testSql(function(tester) {
2014-04-16 02:59:27 -04:00
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
);
2014-04-16 02:50:19 -04:00
});
});
});
};