Skip to content
Mathias Rangel Wulff edited this page Jun 13, 2015 · 6 revisions

Keyword ASSERT

Throws a javascript error if result of last operation is not equal to value (AlaSQL uses equalDeep() function for comparision)

Syntax:

    ASSERT [message,] value;

For example:

    alasql('ASSERT 1');
    alasql('ASSERT “Wrong Value”, @[{a:1,b:”Odessa”}]');

You can use AlaSQL ASSERT operator to test results of previous operation:

    ASSERT string | number | boolean | array | object

For example:

    CREATE TABLE one (a INT);
    ASSERT 1;
    INSERT INTO one VALUES (1),(2),(3);
    ASSERT 3;
    SELECT * FROM one ORDER BY a DESC;
    ASSERT [{a:3},{a:2},{a:1}];

ASSERT statement uses regular JSON notation for the object.

Clone this wiki locally