forked from AlaSQL/alasql
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AlaSQL#2027 sqlCache retains data (and other properties), possible me…
…mory leak AlaSQL#2027 - Remove the `data` property from the sql cache after executing the query
- Loading branch information
1 parent
0dd3a6f
commit 8bbc1d8
Showing
2 changed files
with
51 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
const alasql = require('../dist/alasql.js'); | ||
|
||
if (typeof exports === 'object') { | ||
var assert = require('assert'); | ||
} | ||
|
||
describe('Test 2007 - SQL cache', function () { | ||
before(function () { | ||
alasql('create database test'); | ||
alasql('use test'); | ||
}); | ||
|
||
after(function () { | ||
alasql('drop database test'); | ||
}); | ||
|
||
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'); | ||
|
||
assert.deepEqual(alasql.databases["test"].sqlCache["-169125189"].query.data, []); | ||
|
||
// Execute same query from cache again, the cache is hit now | ||
alasql('SELECT * FROM osoby'); | ||
|
||
// Cache should still be empty for "data" | ||
assert.deepEqual(alasql.databases["test"].sqlCache["-169125189"].query.data, []); | ||
}); | ||
}); |