Skip to content

Commit f9f6e75

Browse files
Copilotmathiasrw
andauthored
Regression test for DELETE without WHERE confirming #856 is fixed (#2190)
Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: mathiasrw <[email protected]> Co-authored-by: Mathias Wulff <[email protected]>
1 parent 28b1be2 commit f9f6e75

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

test/test856.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
if (typeof exports === 'object') {
2+
var assert = require('assert');
3+
var alasql = require('..');
4+
}
5+
6+
var test = '856'; // insert test file number
7+
8+
describe('Test ' + test + ' - DELETE without WHERE clause', function () {
9+
before(function () {
10+
alasql('DROP TABLE IF EXISTS test856table');
11+
alasql('CREATE TABLE test856table (id INT, name STRING)');
12+
});
13+
14+
after(function () {
15+
alasql('DROP TABLE test856table');
16+
});
17+
18+
it('1. DELETE without WHERE should delete all rows', function () {
19+
alasql('INSERT INTO test856table VALUES (1, "Alice"), (2, "Bob"), (3, "Charlie")');
20+
var res = alasql('SELECT * FROM test856table');
21+
assert.equal(res.length, 3);
22+
23+
var deletedCount = alasql('DELETE FROM test856table');
24+
assert.equal(deletedCount, 3, 'Should delete 3 rows');
25+
26+
var res2 = alasql('SELECT * FROM test856table');
27+
assert.equal(res2.length, 0, 'Table should be empty after DELETE');
28+
});
29+
30+
it('2. DELETE without WHERE on fresh data', function () {
31+
alasql('INSERT INTO test856table VALUES (1, "Test1"), (2, "Test2")');
32+
var res = alasql('SELECT * FROM test856table');
33+
assert.equal(res.length, 2);
34+
35+
var deletedCount = alasql('DELETE FROM test856table');
36+
assert.equal(deletedCount, 2, 'Should delete 2 rows');
37+
38+
var res2 = alasql('SELECT * FROM test856table');
39+
assert.equal(res2.length, 0, 'Table should be empty after DELETE');
40+
});
41+
});

0 commit comments

Comments
 (0)