From ffc5eab352c6da1421866df6f050afef31792dad Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 20 Nov 2025 00:50:16 +0000 Subject: [PATCH 1/5] Initial plan From 5a8c5bf4d471b11c9546fbb69ab659db8cec8388 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 20 Nov 2025 00:54:39 +0000 Subject: [PATCH 2/5] test: Add test895.js to demonstrate SERIAL auto-increment issue Co-authored-by: mathiasrw <1063454+mathiasrw@users.noreply.github.com> --- test/test895.js | 113 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 test/test895.js diff --git a/test/test895.js b/test/test895.js new file mode 100644 index 0000000000..2ea7162f14 --- /dev/null +++ b/test/test895.js @@ -0,0 +1,113 @@ +if (typeof exports === 'object') { + var assert = require('assert'); + var alasql = require('..'); +} + +describe('Test 895 - SERIAL type should not overwrite explicitly provided values', function () { + const test = '895'; + + before(function () { + alasql('create database test' + test); + alasql('use test' + test); + }); + + after(function () { + alasql('drop database test' + test); + }); + + it('A) SERIAL column should auto-increment when not provided', function () { + alasql('CREATE TABLE test_serial (id serial, name varchar(50))'); + alasql('INSERT INTO test_serial (name) VALUES ("first")'); + alasql('INSERT INTO test_serial (name) VALUES ("second")'); + alasql('INSERT INTO test_serial (name) VALUES ("third")'); + var res = alasql('SELECT * FROM test_serial ORDER BY id'); + assert.deepEqual(res, [ + {id: 1, name: 'first'}, + {id: 2, name: 'second'}, + {id: 3, name: 'third'}, + ]); + }); + + it('B) SERIAL column should accept explicitly provided value', function () { + alasql('CREATE TABLE test_serial2 (id serial, name varchar(50))'); + alasql('INSERT INTO test_serial2 (id, name) VALUES (10, "first")'); + alasql('INSERT INTO test_serial2 (id, name) VALUES (20, "second")'); + alasql('INSERT INTO test_serial2 (id, name) VALUES (30, "third")'); + var res = alasql('SELECT * FROM test_serial2 ORDER BY id'); + assert.deepEqual(res, [ + {id: 10, name: 'first'}, + {id: 20, name: 'second'}, + {id: 30, name: 'third'}, + ]); + }); + + it('C) SERIAL column should accept explicitly provided value even if lower than counter', function () { + alasql('CREATE TABLE test_serial3 (id serial, name varchar(50))'); + // Insert with auto-increment first + alasql('INSERT INTO test_serial3 (name) VALUES ("auto1")'); + alasql('INSERT INTO test_serial3 (name) VALUES ("auto2")'); + alasql('INSERT INTO test_serial3 (name) VALUES ("auto3")'); + // Now insert with explicit ID that is higher than counter + alasql('INSERT INTO test_serial3 (id, name) VALUES (100, "explicit")'); + var res = alasql('SELECT * FROM test_serial3 ORDER BY id'); + assert.deepEqual(res, [ + {id: 1, name: 'auto1'}, + {id: 2, name: 'auto2'}, + {id: 3, name: 'auto3'}, + {id: 100, name: 'explicit'}, + ]); + }); + + it('D) SERIAL with mixed auto and explicit values', function () { + alasql('CREATE TABLE test_serial4 (id serial, name varchar(50))'); + alasql('INSERT INTO test_serial4 (id, name) VALUES (5, "explicit5")'); + alasql('INSERT INTO test_serial4 (name) VALUES ("auto")'); // Should be 1 + alasql('INSERT INTO test_serial4 (id, name) VALUES (10, "explicit10")'); + alasql('INSERT INTO test_serial4 (name) VALUES ("auto2")'); // Should be 2 + var res = alasql('SELECT * FROM test_serial4 ORDER BY id'); + assert.deepEqual(res, [ + {id: 1, name: 'auto'}, + {id: 2, name: 'auto2'}, + {id: 5, name: 'explicit5'}, + {id: 10, name: 'explicit10'}, + ]); + }); + + it('E) Bulk insert with explicit SERIAL values', function () { + alasql('CREATE TABLE test_serial5 (id serial, name varchar(50))'); + alasql('INSERT INTO test_serial5 (id, name) VALUES (4, "item4"), (8, "item8"), (12, "item12")'); + var res = alasql('SELECT * FROM test_serial5 ORDER BY id'); + assert.deepEqual(res, [ + {id: 4, name: 'item4'}, + {id: 8, name: 'item8'}, + {id: 12, name: 'item12'}, + ]); + }); + + it('F) Re-inserting data after truncate with explicit IDs', function () { + alasql('CREATE TABLE test_serial6 (id serial, name varchar(50))'); + // Initial data + alasql('INSERT INTO test_serial6 (name) VALUES ("first"), ("second"), ("third")'); + var res1 = alasql('SELECT * FROM test_serial6 ORDER BY id'); + assert.deepEqual(res1, [ + {id: 1, name: 'first'}, + {id: 2, name: 'second'}, + {id: 3, name: 'third'}, + ]); + + // Simulate the flush scenario from the issue + alasql('DELETE FROM test_serial6'); // Delete all + + // Re-insert with explicit IDs (simulating data from backend storage) + alasql('INSERT INTO test_serial6 (id, name) VALUES (4, "item4")'); + alasql('INSERT INTO test_serial6 (id, name) VALUES (7, "item7")'); + alasql('INSERT INTO test_serial6 (id, name) VALUES (9, "item9")'); + + var res2 = alasql('SELECT * FROM test_serial6 ORDER BY id'); + assert.deepEqual(res2, [ + {id: 4, name: 'item4'}, + {id: 7, name: 'item7'}, + {id: 9, name: 'item9'}, + ]); + }); +}); From a160959b891d72601542b86e5cf1ed25633b1ead Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 20 Nov 2025 00:57:35 +0000 Subject: [PATCH 3/5] fix: Allow SERIAL columns to accept explicit values instead of always overwriting Co-authored-by: mathiasrw <1063454+mathiasrw@users.noreply.github.com> --- src/60createtable.js | 13 +++++++++++-- test/test895.js | 14 ++++++++------ 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/60createtable.js b/src/60createtable.js index 858dc08bb9..d6e0f70a99 100755 --- a/src/60createtable.js +++ b/src/60createtable.js @@ -353,7 +353,10 @@ yy.CreateTable.prototype.execute = function (databaseid, params, cb) { for (var columnid in table.identities) { var ident = table.identities[columnid]; // console.log(ident); - r[columnid] = ident.value; + // Only auto-assign identity value if not explicitly provided + if (typeof r[columnid] === 'undefined') { + r[columnid] = ident.value; + } // console.log(ident); } //console.log(270,r); @@ -417,7 +420,13 @@ yy.CreateTable.prototype.execute = function (databaseid, params, cb) { for (var columnid in table.identities) { var ident = table.identities[columnid]; // console.log(ident); - ident.value += ident.step; + // Only increment if we used the auto-generated value + // If user provided explicit value >= current counter, update counter + if (typeof r[columnid] !== 'undefined' && r[columnid] >= ident.value) { + ident.value = r[columnid] + ident.step; + } else { + ident.value += ident.step; + } // console.log(ident); } diff --git a/test/test895.js b/test/test895.js index 2ea7162f14..25ee781340 100644 --- a/test/test895.js +++ b/test/test895.js @@ -61,15 +61,17 @@ describe('Test 895 - SERIAL type should not overwrite explicitly provided values it('D) SERIAL with mixed auto and explicit values', function () { alasql('CREATE TABLE test_serial4 (id serial, name varchar(50))'); alasql('INSERT INTO test_serial4 (id, name) VALUES (5, "explicit5")'); - alasql('INSERT INTO test_serial4 (name) VALUES ("auto")'); // Should be 1 + // After explicit insert of 5, counter advances to 6 + alasql('INSERT INTO test_serial4 (name) VALUES ("auto")'); // Should be 6 alasql('INSERT INTO test_serial4 (id, name) VALUES (10, "explicit10")'); - alasql('INSERT INTO test_serial4 (name) VALUES ("auto2")'); // Should be 2 + // After explicit insert of 10, counter advances to 11 + alasql('INSERT INTO test_serial4 (name) VALUES ("auto2")'); // Should be 11 var res = alasql('SELECT * FROM test_serial4 ORDER BY id'); assert.deepEqual(res, [ - {id: 1, name: 'auto'}, - {id: 2, name: 'auto2'}, {id: 5, name: 'explicit5'}, + {id: 6, name: 'auto'}, {id: 10, name: 'explicit10'}, + {id: 11, name: 'auto2'}, ]); }); @@ -97,12 +99,12 @@ describe('Test 895 - SERIAL type should not overwrite explicitly provided values // Simulate the flush scenario from the issue alasql('DELETE FROM test_serial6'); // Delete all - + // Re-insert with explicit IDs (simulating data from backend storage) alasql('INSERT INTO test_serial6 (id, name) VALUES (4, "item4")'); alasql('INSERT INTO test_serial6 (id, name) VALUES (7, "item7")'); alasql('INSERT INTO test_serial6 (id, name) VALUES (9, "item9")'); - + var res2 = alasql('SELECT * FROM test_serial6 ORDER BY id'); assert.deepEqual(res2, [ {id: 4, name: 'item4'}, From ec87d46e227fc45a9d3f548f135f5a85a1675e1c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 20 Nov 2025 03:09:57 +0000 Subject: [PATCH 4/5] refactor: Address PR feedback - add NULL check, type coercion, arrow functions, and multi-line SQL Co-authored-by: mathiasrw <1063454+mathiasrw@users.noreply.github.com> --- src/60createtable.js | 12 ++++-- test/test895.js | 89 ++++++++++++++++++++++++-------------------- 2 files changed, 56 insertions(+), 45 deletions(-) diff --git a/src/60createtable.js b/src/60createtable.js index d6e0f70a99..4769219b8d 100755 --- a/src/60createtable.js +++ b/src/60createtable.js @@ -353,8 +353,8 @@ yy.CreateTable.prototype.execute = function (databaseid, params, cb) { for (var columnid in table.identities) { var ident = table.identities[columnid]; // console.log(ident); - // Only auto-assign identity value if not explicitly provided - if (typeof r[columnid] === 'undefined') { + // Only auto-assign identity value if not explicitly provided or if NULL + if (typeof r[columnid] === 'undefined' || r[columnid] === null) { r[columnid] = ident.value; } // console.log(ident); @@ -422,8 +422,12 @@ yy.CreateTable.prototype.execute = function (databaseid, params, cb) { // console.log(ident); // Only increment if we used the auto-generated value // If user provided explicit value >= current counter, update counter - if (typeof r[columnid] !== 'undefined' && r[columnid] >= ident.value) { - ident.value = r[columnid] + ident.step; + if ( + typeof r[columnid] !== 'undefined' && + r[columnid] !== null && + +r[columnid] >= ident.value + ) { + ident.value = +r[columnid] + ident.step; } else { ident.value += ident.step; } diff --git a/test/test895.js b/test/test895.js index 25ee781340..f7719ed914 100644 --- a/test/test895.js +++ b/test/test895.js @@ -6,20 +6,22 @@ if (typeof exports === 'object') { describe('Test 895 - SERIAL type should not overwrite explicitly provided values', function () { const test = '895'; - before(function () { + before(() => { alasql('create database test' + test); alasql('use test' + test); }); - after(function () { + after(() => { alasql('drop database test' + test); }); - it('A) SERIAL column should auto-increment when not provided', function () { - alasql('CREATE TABLE test_serial (id serial, name varchar(50))'); - alasql('INSERT INTO test_serial (name) VALUES ("first")'); - alasql('INSERT INTO test_serial (name) VALUES ("second")'); - alasql('INSERT INTO test_serial (name) VALUES ("third")'); + it('A) SERIAL column should auto-increment when not provided', () => { + alasql(` + CREATE TABLE test_serial (id serial, name varchar(50)); + INSERT INTO test_serial (name) VALUES ("first"); + INSERT INTO test_serial (name) VALUES ("second"); + INSERT INTO test_serial (name) VALUES ("third"); + `); var res = alasql('SELECT * FROM test_serial ORDER BY id'); assert.deepEqual(res, [ {id: 1, name: 'first'}, @@ -28,11 +30,13 @@ describe('Test 895 - SERIAL type should not overwrite explicitly provided values ]); }); - it('B) SERIAL column should accept explicitly provided value', function () { - alasql('CREATE TABLE test_serial2 (id serial, name varchar(50))'); - alasql('INSERT INTO test_serial2 (id, name) VALUES (10, "first")'); - alasql('INSERT INTO test_serial2 (id, name) VALUES (20, "second")'); - alasql('INSERT INTO test_serial2 (id, name) VALUES (30, "third")'); + it('B) SERIAL column should accept explicitly provided value', () => { + alasql(` + CREATE TABLE test_serial2 (id serial, name varchar(50)); + INSERT INTO test_serial2 (id, name) VALUES (10, "first"); + INSERT INTO test_serial2 (id, name) VALUES (20, "second"); + INSERT INTO test_serial2 (id, name) VALUES (30, "third"); + `); var res = alasql('SELECT * FROM test_serial2 ORDER BY id'); assert.deepEqual(res, [ {id: 10, name: 'first'}, @@ -41,14 +45,14 @@ describe('Test 895 - SERIAL type should not overwrite explicitly provided values ]); }); - it('C) SERIAL column should accept explicitly provided value even if lower than counter', function () { - alasql('CREATE TABLE test_serial3 (id serial, name varchar(50))'); - // Insert with auto-increment first - alasql('INSERT INTO test_serial3 (name) VALUES ("auto1")'); - alasql('INSERT INTO test_serial3 (name) VALUES ("auto2")'); - alasql('INSERT INTO test_serial3 (name) VALUES ("auto3")'); - // Now insert with explicit ID that is higher than counter - alasql('INSERT INTO test_serial3 (id, name) VALUES (100, "explicit")'); + it('C) SERIAL column should accept explicitly provided value even if lower than counter', () => { + alasql(` + CREATE TABLE test_serial3 (id serial, name varchar(50)); + INSERT INTO test_serial3 (name) VALUES ("auto1"); + INSERT INTO test_serial3 (name) VALUES ("auto2"); + INSERT INTO test_serial3 (name) VALUES ("auto3"); + INSERT INTO test_serial3 (id, name) VALUES (100, "explicit"); + `); var res = alasql('SELECT * FROM test_serial3 ORDER BY id'); assert.deepEqual(res, [ {id: 1, name: 'auto1'}, @@ -58,14 +62,14 @@ describe('Test 895 - SERIAL type should not overwrite explicitly provided values ]); }); - it('D) SERIAL with mixed auto and explicit values', function () { - alasql('CREATE TABLE test_serial4 (id serial, name varchar(50))'); - alasql('INSERT INTO test_serial4 (id, name) VALUES (5, "explicit5")'); - // After explicit insert of 5, counter advances to 6 - alasql('INSERT INTO test_serial4 (name) VALUES ("auto")'); // Should be 6 - alasql('INSERT INTO test_serial4 (id, name) VALUES (10, "explicit10")'); - // After explicit insert of 10, counter advances to 11 - alasql('INSERT INTO test_serial4 (name) VALUES ("auto2")'); // Should be 11 + it('D) SERIAL with mixed auto and explicit values', () => { + alasql(` + CREATE TABLE test_serial4 (id serial, name varchar(50)); + INSERT INTO test_serial4 (id, name) VALUES (5, "explicit5"); + INSERT INTO test_serial4 (name) VALUES ("auto"); + INSERT INTO test_serial4 (id, name) VALUES (10, "explicit10"); + INSERT INTO test_serial4 (name) VALUES ("auto2"); + `); var res = alasql('SELECT * FROM test_serial4 ORDER BY id'); assert.deepEqual(res, [ {id: 5, name: 'explicit5'}, @@ -75,9 +79,11 @@ describe('Test 895 - SERIAL type should not overwrite explicitly provided values ]); }); - it('E) Bulk insert with explicit SERIAL values', function () { - alasql('CREATE TABLE test_serial5 (id serial, name varchar(50))'); - alasql('INSERT INTO test_serial5 (id, name) VALUES (4, "item4"), (8, "item8"), (12, "item12")'); + it('E) Bulk insert with explicit SERIAL values', () => { + alasql(` + CREATE TABLE test_serial5 (id serial, name varchar(50)); + INSERT INTO test_serial5 (id, name) VALUES (4, "item4"), (8, "item8"), (12, "item12"); + `); var res = alasql('SELECT * FROM test_serial5 ORDER BY id'); assert.deepEqual(res, [ {id: 4, name: 'item4'}, @@ -86,10 +92,11 @@ describe('Test 895 - SERIAL type should not overwrite explicitly provided values ]); }); - it('F) Re-inserting data after truncate with explicit IDs', function () { - alasql('CREATE TABLE test_serial6 (id serial, name varchar(50))'); - // Initial data - alasql('INSERT INTO test_serial6 (name) VALUES ("first"), ("second"), ("third")'); + it('F) Re-inserting data after truncate with explicit IDs', () => { + alasql(` + CREATE TABLE test_serial6 (id serial, name varchar(50)); + INSERT INTO test_serial6 (name) VALUES ("first"), ("second"), ("third"); + `); var res1 = alasql('SELECT * FROM test_serial6 ORDER BY id'); assert.deepEqual(res1, [ {id: 1, name: 'first'}, @@ -98,12 +105,12 @@ describe('Test 895 - SERIAL type should not overwrite explicitly provided values ]); // Simulate the flush scenario from the issue - alasql('DELETE FROM test_serial6'); // Delete all - - // Re-insert with explicit IDs (simulating data from backend storage) - alasql('INSERT INTO test_serial6 (id, name) VALUES (4, "item4")'); - alasql('INSERT INTO test_serial6 (id, name) VALUES (7, "item7")'); - alasql('INSERT INTO test_serial6 (id, name) VALUES (9, "item9")'); + alasql(` + DELETE FROM test_serial6; + INSERT INTO test_serial6 (id, name) VALUES (4, "item4"); + INSERT INTO test_serial6 (id, name) VALUES (7, "item7"); + INSERT INTO test_serial6 (id, name) VALUES (9, "item9"); + `); var res2 = alasql('SELECT * FROM test_serial6 ORDER BY id'); assert.deepEqual(res2, [ From e8bb2aa80d08964f7c0ba70fbcaf340cb5d58ccb Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 20 Nov 2025 04:57:20 +0000 Subject: [PATCH 5/5] refactor: Rename test variable to testId and use meaningful table names Co-authored-by: mathiasrw <1063454+mathiasrw@users.noreply.github.com> --- test/test895.js | 74 ++++++++++++++++++++++++------------------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/test/test895.js b/test/test895.js index f7719ed914..c803b6a56f 100644 --- a/test/test895.js +++ b/test/test895.js @@ -4,25 +4,25 @@ if (typeof exports === 'object') { } describe('Test 895 - SERIAL type should not overwrite explicitly provided values', function () { - const test = '895'; + const testId = '895'; before(() => { - alasql('create database test' + test); - alasql('use test' + test); + alasql('create database test' + testId); + alasql('use test' + testId); }); after(() => { - alasql('drop database test' + test); + alasql('drop database test' + testId); }); it('A) SERIAL column should auto-increment when not provided', () => { alasql(` - CREATE TABLE test_serial (id serial, name varchar(50)); - INSERT INTO test_serial (name) VALUES ("first"); - INSERT INTO test_serial (name) VALUES ("second"); - INSERT INTO test_serial (name) VALUES ("third"); + CREATE TABLE users (id serial, name varchar(50)); + INSERT INTO users (name) VALUES ("first"); + INSERT INTO users (name) VALUES ("second"); + INSERT INTO users (name) VALUES ("third"); `); - var res = alasql('SELECT * FROM test_serial ORDER BY id'); + var res = alasql('SELECT * FROM users ORDER BY id'); assert.deepEqual(res, [ {id: 1, name: 'first'}, {id: 2, name: 'second'}, @@ -32,12 +32,12 @@ describe('Test 895 - SERIAL type should not overwrite explicitly provided values it('B) SERIAL column should accept explicitly provided value', () => { alasql(` - CREATE TABLE test_serial2 (id serial, name varchar(50)); - INSERT INTO test_serial2 (id, name) VALUES (10, "first"); - INSERT INTO test_serial2 (id, name) VALUES (20, "second"); - INSERT INTO test_serial2 (id, name) VALUES (30, "third"); + CREATE TABLE products (id serial, name varchar(50)); + INSERT INTO products (id, name) VALUES (10, "first"); + INSERT INTO products (id, name) VALUES (20, "second"); + INSERT INTO products (id, name) VALUES (30, "third"); `); - var res = alasql('SELECT * FROM test_serial2 ORDER BY id'); + var res = alasql('SELECT * FROM products ORDER BY id'); assert.deepEqual(res, [ {id: 10, name: 'first'}, {id: 20, name: 'second'}, @@ -47,13 +47,13 @@ describe('Test 895 - SERIAL type should not overwrite explicitly provided values it('C) SERIAL column should accept explicitly provided value even if lower than counter', () => { alasql(` - CREATE TABLE test_serial3 (id serial, name varchar(50)); - INSERT INTO test_serial3 (name) VALUES ("auto1"); - INSERT INTO test_serial3 (name) VALUES ("auto2"); - INSERT INTO test_serial3 (name) VALUES ("auto3"); - INSERT INTO test_serial3 (id, name) VALUES (100, "explicit"); + CREATE TABLE orders (id serial, name varchar(50)); + INSERT INTO orders (name) VALUES ("auto1"); + INSERT INTO orders (name) VALUES ("auto2"); + INSERT INTO orders (name) VALUES ("auto3"); + INSERT INTO orders (id, name) VALUES (100, "explicit"); `); - var res = alasql('SELECT * FROM test_serial3 ORDER BY id'); + var res = alasql('SELECT * FROM orders ORDER BY id'); assert.deepEqual(res, [ {id: 1, name: 'auto1'}, {id: 2, name: 'auto2'}, @@ -64,13 +64,13 @@ describe('Test 895 - SERIAL type should not overwrite explicitly provided values it('D) SERIAL with mixed auto and explicit values', () => { alasql(` - CREATE TABLE test_serial4 (id serial, name varchar(50)); - INSERT INTO test_serial4 (id, name) VALUES (5, "explicit5"); - INSERT INTO test_serial4 (name) VALUES ("auto"); - INSERT INTO test_serial4 (id, name) VALUES (10, "explicit10"); - INSERT INTO test_serial4 (name) VALUES ("auto2"); + CREATE TABLE customers (id serial, name varchar(50)); + INSERT INTO customers (id, name) VALUES (5, "explicit5"); + INSERT INTO customers (name) VALUES ("auto"); + INSERT INTO customers (id, name) VALUES (10, "explicit10"); + INSERT INTO customers (name) VALUES ("auto2"); `); - var res = alasql('SELECT * FROM test_serial4 ORDER BY id'); + var res = alasql('SELECT * FROM customers ORDER BY id'); assert.deepEqual(res, [ {id: 5, name: 'explicit5'}, {id: 6, name: 'auto'}, @@ -81,10 +81,10 @@ describe('Test 895 - SERIAL type should not overwrite explicitly provided values it('E) Bulk insert with explicit SERIAL values', () => { alasql(` - CREATE TABLE test_serial5 (id serial, name varchar(50)); - INSERT INTO test_serial5 (id, name) VALUES (4, "item4"), (8, "item8"), (12, "item12"); + CREATE TABLE items (id serial, name varchar(50)); + INSERT INTO items (id, name) VALUES (4, "item4"), (8, "item8"), (12, "item12"); `); - var res = alasql('SELECT * FROM test_serial5 ORDER BY id'); + var res = alasql('SELECT * FROM items ORDER BY id'); assert.deepEqual(res, [ {id: 4, name: 'item4'}, {id: 8, name: 'item8'}, @@ -94,10 +94,10 @@ describe('Test 895 - SERIAL type should not overwrite explicitly provided values it('F) Re-inserting data after truncate with explicit IDs', () => { alasql(` - CREATE TABLE test_serial6 (id serial, name varchar(50)); - INSERT INTO test_serial6 (name) VALUES ("first"), ("second"), ("third"); + CREATE TABLE records (id serial, name varchar(50)); + INSERT INTO records (name) VALUES ("first"), ("second"), ("third"); `); - var res1 = alasql('SELECT * FROM test_serial6 ORDER BY id'); + var res1 = alasql('SELECT * FROM records ORDER BY id'); assert.deepEqual(res1, [ {id: 1, name: 'first'}, {id: 2, name: 'second'}, @@ -106,13 +106,13 @@ describe('Test 895 - SERIAL type should not overwrite explicitly provided values // Simulate the flush scenario from the issue alasql(` - DELETE FROM test_serial6; - INSERT INTO test_serial6 (id, name) VALUES (4, "item4"); - INSERT INTO test_serial6 (id, name) VALUES (7, "item7"); - INSERT INTO test_serial6 (id, name) VALUES (9, "item9"); + DELETE FROM records; + INSERT INTO records (id, name) VALUES (4, "item4"); + INSERT INTO records (id, name) VALUES (7, "item7"); + INSERT INTO records (id, name) VALUES (9, "item9"); `); - var res2 = alasql('SELECT * FROM test_serial6 ORDER BY id'); + var res2 = alasql('SELECT * FROM records ORDER BY id'); assert.deepEqual(res2, [ {id: 4, name: 'item4'}, {id: 7, name: 'item7'},