Skip to content

primary key not working. Adds duplicate values. #1292

@carper7

Description

@carper7

I have the following code but it is not working:

alasql("create INDEXEDDB DATABASE if not exists localdb_db");
alasql("ATTACH INDEXEDDB DATABASE localdb_db; \ CREATE TABLE if not exists localdb_db.db_Settings(**setting varchar(50) Primary Key**, `value` varchar(300), storeInSession varchar(1) DEFAULT 'N')", function(res) {
             console.log(res + " :indexedDB");	
 });
		 
alasql("ATTACH INDEXEDDB DATABASE localdb_db; \ INSERT INTO localdb_db.db_Settings (setting,`value` ) values(?,?)", ["domain", "http"], function(res) {
             console.log(res);	
 });
         
alasql("ATTACH INDEXEDDB DATABASE localdb_db; \ INSERT INTO localkics_db.db_Settings (setting, `value` ) values(?,?)", ["domain", "https"], function(res) {
             //console.log(res);	
 });
		 
alasql("ATTACH INDEXEDDB DATABASE localdb_db; \ SELECT * FROM localdb_db.db_Settings", [], function(res) {
             console.log(res);
         });

It does not create the primary key [setting] therefore it allows me to insert duplicates. For some reason it is automatically creating its own key. I even tried by using string instead of varchar.

'#' |Key | Value
0 | 1 | {setting: “domain”, value: ”http”}
1 | 2 | {setting: “domain”, value: ”https”}

Could you please advise me what to do here?

Thank You.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions