From d16b500b412d92ef3e47abe7c98556ca97de8597 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 19 Nov 2025 09:54:11 +0000 Subject: [PATCH 1/3] Initial plan From 00e34c7928498b15bc3d78cb88f8d782109b84e8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 19 Nov 2025 09:57:54 +0000 Subject: [PATCH 2/3] Add test856.js to verify DELETE without WHERE clause works correctly Co-authored-by: mathiasrw <1063454+mathiasrw@users.noreply.github.com> --- test/test856.js | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 test/test856.js diff --git a/test/test856.js b/test/test856.js new file mode 100644 index 0000000000..7405b7d9ca --- /dev/null +++ b/test/test856.js @@ -0,0 +1,48 @@ +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 () { + it('1. Create test table', function (done) { + alasql('DROP TABLE IF EXISTS test856table'); + alasql('CREATE TABLE test856table (id INT, name STRING)'); + done(); + }); + + it('2. Insert test data', function (done) { + alasql('INSERT INTO test856table VALUES (1, "Alice"), (2, "Bob"), (3, "Charlie")'); + var res = alasql('SELECT * FROM test856table'); + assert.equal(res.length, 3); + done(); + }); + + it('3. DELETE without WHERE should delete all rows', function (done) { + var deletedCount = alasql('DELETE FROM test856table'); + assert.equal(deletedCount, 3, 'Should delete 3 rows'); + + var res = alasql('SELECT * FROM test856table'); + assert.equal(res.length, 0, 'Table should be empty after DELETE'); + done(); + }); + + it('4. Test DELETE without WHERE on fresh data', function (done) { + 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'); + done(); + }); + + it('5. Cleanup', function (done) { + alasql('DROP TABLE test856table'); + done(); + }); +}); From c7f65f43ebc70a2d628dad36cbe0da757b83c0ea Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 19 Nov 2025 12:43:45 +0000 Subject: [PATCH 3/3] Refactor test856.js to use before/after hooks and remove done callbacks Co-authored-by: mathiasrw <1063454+mathiasrw@users.noreply.github.com> --- test/test856.js | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/test/test856.js b/test/test856.js index 7405b7d9ca..ffd5f76679 100644 --- a/test/test856.js +++ b/test/test856.js @@ -6,43 +6,36 @@ if (typeof exports === 'object') { var test = '856'; // insert test file number describe('Test ' + test + ' - DELETE without WHERE clause', function () { - it('1. Create test table', function (done) { + before(function () { alasql('DROP TABLE IF EXISTS test856table'); alasql('CREATE TABLE test856table (id INT, name STRING)'); - done(); }); - it('2. Insert test data', function (done) { + 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); - done(); - }); - it('3. DELETE without WHERE should delete all rows', function (done) { var deletedCount = alasql('DELETE FROM test856table'); assert.equal(deletedCount, 3, 'Should delete 3 rows'); - - var res = alasql('SELECT * FROM test856table'); - assert.equal(res.length, 0, 'Table should be empty after DELETE'); - done(); + + var res2 = alasql('SELECT * FROM test856table'); + assert.equal(res2.length, 0, 'Table should be empty after DELETE'); }); - it('4. Test DELETE without WHERE on fresh data', function (done) { + 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'); - done(); - }); - - it('5. Cleanup', function (done) { - alasql('DROP TABLE test856table'); - done(); }); });