Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling parser with backtick #1512

Draft
wants to merge 10 commits into
base: v5
Choose a base branch
from
Prev Previous commit
Next Next commit
Rename test files
mathiasrw committed Jun 14, 2023
commit 632f548d8a3da417ebb0d291c8820ec36af8f2ff
20 changes: 10 additions & 10 deletions test/test000.js
Original file line number Diff line number Diff line change
@@ -3,20 +3,20 @@ if (typeof exports === 'object') {
var alasql = require('..');
}

var test = '000'; // insert test file number
const testID = '000'; // Seek to use a github issue number

describe('Test ' + test + ' - multiple statements', function () {
describe('Issue #' + testID + ' - multiple statements', function () {
before(function () {
alasql('create database test' + test);
alasql('use test' + test);
alasql('create database test' + testID);
alasql('use test' + testID);
});

after(function () {
alasql('drop database test' + test);
alasql('drop database test' + testID);
});

it('A) From single lines', function () {
var res = [];
const res = [];
res.push(alasql('create table one (a int)'));
res.push(alasql('insert into one values (1),(2),(3),(4),(5)'));
res.push(alasql('select * from one'));
@@ -25,19 +25,19 @@ describe('Test ' + test + ' - multiple statements', function () {

it('B) Multiple statements in one string', function () {
//
var sql = 'create table two (a int);';
let sql = 'create table two (a int);';
sql += 'insert into two values (1),(2),(3),(4),(5);';
sql += 'select * from two;';
var res = alasql(sql);
let res = alasql(sql);
assert.deepEqual(res, [1, 5, [{a: 1}, {a: 2}, {a: 3}, {a: 4}, {a: 5}]]);
});

it('C) Multiple statements in one string with callback', function (done) {
// Please note that first parameter (here `done`) must be called if defined - and is needed when testing async code
var sql = 'create table three (a int);';
let sql = 'create table three (a int);';
sql += 'insert into three values (1),(2),(3),(4),(5);';
sql += 'select * from three;';
alasql(sql, function (res) {
alasql.promise(sql).then( function (res) {
assert.deepEqual(res, [1, 5, [{a: 1}, {a: 2}, {a: 3}, {a: 4}, {a: 5}]]);
done();
});
7 changes: 1 addition & 6 deletions test/test1512.js → test/test1723a.js
Original file line number Diff line number Diff line change
@@ -3,13 +3,8 @@ if (typeof exports === 'object') {
var alasql = require('../dist/alasql');
}

/*
Test for PR #1512
*/

var test = '1512'; // insert test file number

describe('Test ' + test + ' - tagFunction for template strings', function () {
describe('Issue #1723 - tagFunction for template strings', function () {
it('Will mark free fields as parameters', function (done) {
assert.deepEqual(tagBraid`SELECT 123 as abc`, ['SELECT 123 as abc']);
assert.deepEqual(tagBraid`SELECT ${123} as abc`, ['SELECT ? as abc', [123]]);
6 changes: 3 additions & 3 deletions test/_test847.js → test/test1723b.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
if (typeof exports === 'object') {
var alasql = require('..');
var alasql = require('../dist/alasql');
}

const table = {
@@ -11,7 +11,7 @@ const table = {
],
};

describe('Test 847 - Testing backtick call function', function () {
describe('Issue #1723 - Testing backtick call function', function () {
it('1. Create table', function () {
alasql`DROP TABLE IF EXISTS test`;
alasql`CREATE TABLE test (a int, b int)`;
@@ -49,7 +49,7 @@ describe('Test 847 - Testing backtick call function', function () {
)
.join('');

console.log(valuesToInsert);
//console.log(valuesToInsert);

alasql(`
INSERT INTO ${table.name}