-
Notifications
You must be signed in to change notification settings - Fork 659
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Co-authored-by: asundukov <asundukov>
- Loading branch information
1 parent
2d383d9
commit 85c24d4
Showing
3 changed files
with
49 additions
and
6 deletions.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,45 @@ | ||
if (typeof exports === 'object') { | ||
var assert = require('assert'); | ||
var alasql = require('..'); | ||
} | ||
|
||
describe('Test 1937: EXISTS in SQL Queries and SET Statements', function () { | ||
before(function () { | ||
alasql('create database test1937'); | ||
alasql('use test1937'); | ||
alasql('DROP TABLE IF EXISTS one'); | ||
alasql('CREATE TABLE one (a INT)'); | ||
alasql('INSERT INTO one VALUES (1),(2),(3),(4),(5)'); | ||
}); | ||
|
||
after(function () { | ||
alasql('drop database test1937'); | ||
}); | ||
|
||
it('Nested EXISTS in subquery', function (done) { | ||
const res = alasql( | ||
'SELECT EXISTS(SELECT a FROM one WHERE 0) AS main_exists, * FROM (SELECT EXISTS(SELECT a FROM one) AS sub_exists, a FROM one)' | ||
); | ||
assert.deepEqual( | ||
[ | ||
{main_exists: false, a: 1, sub_exists: true}, | ||
{main_exists: false, a: 2, sub_exists: true}, | ||
{main_exists: false, a: 3, sub_exists: true}, | ||
{main_exists: false, a: 4, sub_exists: true}, | ||
{main_exists: false, a: 5, sub_exists: true}, | ||
], | ||
res | ||
); | ||
done(); | ||
}); | ||
|
||
it('EXISTS in SET statement', function (done) { | ||
const res = alasql( | ||
`SET @existsLessThan3 = (SELECT EXISTS(SELECT a FROM one WHERE a < 3)); | ||
SET @existsGreaterThan10 = (SELECT EXISTS(SELECT a FROM one WHERE a > 10)); | ||
SELECT @existsLessThan3, @existsGreaterThan10;` | ||
); | ||
assert.deepEqual([{'@existsLessThan3': true, '@existsGreaterThan10': false}], res[2]); | ||
done(); | ||
}); | ||
}); |