AlaSQL / alasql

AlaSQL.js - JavaScript SQL database for browser and Node.js. Handles both traditional relational tables and nested JSON data (NoSQL). Export, store, and import data from localStorage, IndexedDB, or Excel.
http://alasql.org
MIT License
7.04k stars 659 forks source link

Default values are ignored in FILESTORAGE and LOCALSTORAGE #1848

Open arximboldi opened 11 months ago

arximboldi commented 11 months ago

I have the following tables:

CREATE TABLE IF NOT EXISTS banks (
       name STRING PRIMARY KEY,
       is_open BOOLEAN DEFAULT true,
       [key] STRING
);

CREATE TABLE IF NOT EXISTS pigs (
       id STRING PRIMARY KEY,
       bank STRING DEFAULT null,
       ready BOOLEAN DEFAULT false,
       dream STRING,
       notes STRING,
       kind STRING,
       timestamp DATETIME DEFAULT CURRENT_TIMESTAMP,
       FOREIGN KEY (bank) REFERENCES bank(name)
);

I have noticed that when I do an INSERT, all unspecified values are left as undefined instead of using any of the DEFAULT specifications.

This has been tested for both FILESTORAGE and LOCALSTORAGE.

jigarBorde commented 10 months ago

Hii @mathiasrw

Noticing default values set during INSERT operations in tables (banks, pigs) where specified defaults exist, they are correctly applied. However, columns without explicitly provided values during retrieval display as 'undefined', which aligns with expectations as no default values were specified for those columns.

Additionally, updated the FOREIGN KEY reference from bank(name) to banks(name) for accuracy.

let me know, if i missed something.

mathiasrw commented 10 months ago

@arximboldi Can you confirm what @jigarBorde said?