From aded88ac8094a71a8ed559615e4150d302fb5e8b Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Thu, 22 Aug 2024 20:32:51 +0200 Subject: fix(storage/schema.sql): Tell SQLite to perform type-checking MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Otherwise, SQLite tries to “coerce” types into fitting in the “preferred” type of the table. Now SQLite actually refuses to accept a type mismatch. --- src/storage/video_database/schema.sql | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/storage/video_database/schema.sql b/src/storage/video_database/schema.sql index b05d908..3afd091 100644 --- a/src/storage/video_database/schema.sql +++ b/src/storage/video_database/schema.sql @@ -8,7 +8,8 @@ -- You should have received a copy of the License along with this program. -- If not, see . --- The base schema +-- All tables should be declared STRICT, as I actually like to have types checking (and a +-- db that doesn't lie to me). -- Keep this table in sync with the `Video` structure CREATE TABLE IF NOT EXISTS videos ( @@ -18,7 +19,7 @@ CREATE TABLE IF NOT EXISTS videos ( 1 END), description TEXT, - duration FLOAT, + duration REAL, extractor_hash TEXT UNIQUE NOT NULL PRIMARY KEY, last_status_change INTEGER NOT NULL, parent_subscription_name TEXT, @@ -39,7 +40,7 @@ CREATE TABLE IF NOT EXISTS videos ( thumbnail_url TEXT, title TEXT NOT NULL, url TEXT UNIQUE NOT NULL -); +) STRICT; -- Store additional metadata for the videos marked to be watched CREATE TABLE IF NOT EXISTS video_options ( @@ -47,10 +48,10 @@ CREATE TABLE IF NOT EXISTS video_options ( subtitle_langs TEXT NOT NULL, playback_speed REAL NOT NULL, FOREIGN KEY(extractor_hash) REFERENCES videos (extractor_hash) -); +) STRICT; -- Store subscriptions CREATE TABLE IF NOT EXISTS subscriptions ( name TEXT UNIQUE NOT NULL PRIMARY KEY, url TEXT NOT NULL -); +) STRICT; -- cgit 1.4.1