Skip to content

Commit

Permalink
AlaSQL#2027 sqlCache retains data (and other properties), possible me…
Browse files Browse the repository at this point in the history
…mory leak AlaSQL#2027

- Add assertions
  • Loading branch information
paulrutter committed Jan 8, 2025
1 parent 8bbc1d8 commit 15d706b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions test/test2027.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,19 @@ describe('Test 2007 - SQL cache', function () {
it('A) Execute query and assert cache for `data` afterwards', () => {
alasql('CREATE TABLE osoby (id INT, meno STRING)');
alasql('INSERT INTO osoby VALUES (1, "John"), (2, "Jane"), (3, "Jake")');
alasql('SELECT * FROM osoby');
var res = alasql('SELECT * FROM osoby');

assert.deepEqual(alasql.databases["test"].sqlCache["-169125189"].query.data, []);
assert.equal(res.length, 3);

// Insert more rows
alasql('INSERT INTO osoby VALUES (4, "Jack"), (5, "Paul")');

// Execute same query from cache again, the cache is hit now
alasql('SELECT * FROM osoby');
var res2 = alasql('SELECT * FROM osoby');

// Cache should still be empty for "data"
assert.deepEqual(alasql.databases["test"].sqlCache["-169125189"].query.data, []);
assert.equal(res2.length, 5);
});
});

0 comments on commit 15d706b

Please sign in to comment.