Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions test/test856.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
if (typeof exports === 'object') {
var assert = require('assert');
var alasql = require('..');
}

var test = '856'; // insert test file number

describe('Test ' + test + ' - DELETE without WHERE clause', function () {
before(function () {
alasql('DROP TABLE IF EXISTS test856table');
alasql('CREATE TABLE test856table (id INT, name STRING)');
});

after(function () {
alasql('DROP TABLE test856table');
});

it('1. DELETE without WHERE should delete all rows', function () {
alasql('INSERT INTO test856table VALUES (1, "Alice"), (2, "Bob"), (3, "Charlie")');
var res = alasql('SELECT * FROM test856table');
assert.equal(res.length, 3);

var deletedCount = alasql('DELETE FROM test856table');
assert.equal(deletedCount, 3, 'Should delete 3 rows');

var res2 = alasql('SELECT * FROM test856table');
assert.equal(res2.length, 0, 'Table should be empty after DELETE');
});

it('2. DELETE without WHERE on fresh data', function () {
alasql('INSERT INTO test856table VALUES (1, "Test1"), (2, "Test2")');
var res = alasql('SELECT * FROM test856table');
assert.equal(res.length, 2);

var deletedCount = alasql('DELETE FROM test856table');
assert.equal(deletedCount, 2, 'Should delete 2 rows');

var res2 = alasql('SELECT * FROM test856table');
assert.equal(res2.length, 0, 'Table should be empty after DELETE');
});
});
Loading