From 95a10dfc6025379165d87c2f3f526df2d92654b3 Mon Sep 17 00:00:00 2001 From: Amaury Date: Sun, 18 Apr 2021 16:19:38 +0200 Subject: [PATCH] sepcify not null sqlite to prevent some issues --- src/sqlite-tools.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/sqlite-tools.ts b/src/sqlite-tools.ts index 890d77d..e84ed7c 100644 --- a/src/sqlite-tools.ts +++ b/src/sqlite-tools.ts @@ -15,9 +15,9 @@ export class SqliteTools { let req = sql`CREATE TABLE IF NOT EXISTS listeners ( address TEXT NOT NULL UNIQUE, - customfields TEXT DEFAULT '[]', - timeloop INTEGER DEFAULT 300, - last_entries_links TEXT DEFAULT '[]', + customfields TEXT DEFAULT '[]' NOT NULL, + timeloop INTEGER DEFAULT 300 NOT NULL, + last_entries_links TEXT DEFAULT '[]' NOT NULL, PRIMARY KEY (address), CHECK(timeloop >= 0) );`; @@ -47,8 +47,8 @@ export class SqliteTools { let req = sql`INSERT INTO listeners (address, timeloop, customfields, last_entries_links) VALUES (${listener.address}, ${listener.timeloop}, - ${JSON.stringify(listener.customfields)}, - ${JSON.stringify(listener.lastEntriesLinks)})`; + ${JSON.stringify(listener.customfields ? listener.customfields : [])}, + ${JSON.stringify(listener.lastEntriesLinks ? listener.lastEntriesLinks : [])})`; await db.query(req); await db.dispose(); }