Skip to content

Sqlite parse error on CHECK constraint #505

@darkfeline

Description

@darkfeline

I get an error when I try to modify the following table:

Sqlite parse error:  "line 5:72: unexpected token: NULL" ( "CREATE TABLE \"anime\" (\n\t`id`\tINTEGER,\n\t`name`\ttext NOT NULL,\n\t`type`\tTEXT NOT NULL,\n\t`ep_watched`\tinteger NOT NULL DEFAULT 0 CHECK(`ep_total` is NULL or `ep_watched` <= `ep_total`),\n\t`ep_total`\tinteger DEFAULT NULL,\n\t`status`\tTEXT NOT NULL,\n\t`date_started`\ttext DEFAULT NULL,\n\t`date_finished`\ttext DEFAULT NULL,\n\t`animedb_id`\tinteger NOT NULL UNIQUE,\n\t`anidb_id`\tINTEGER UNIQUE,\n\tPRIMARY KEY(id),\n\tFOREIGN KEY(`type`) REFERENCES anime_types ( type ) on delete restrict on update cascade,\n\tFOREIGN KEY(`status`) REFERENCES anime_statuses ( status ) on delete restrict on update cascade\n)" )

Here's a cleaned up version:

Sqlite parse error:  "line 5:72: unexpected token: NULL"

( "CREATE TABLE \"anime\" (
    `id`    INTEGER,
    `name`  text NOT NULL,
    `type`  TEXT NOT NULL,
    `ep_watched`    integer NOT NULL DEFAULT 0 CHECK(`ep_total` is NULL or `ep_watched` <= `ep_total`),
    `ep_total`  integer DEFAULT NULL,
    `status`    TEXT NOT NULL,
    `date_started`  text DEFAULT NULL,
    `date_finished` text DEFAULT NULL,
    `animedb_id`    integer NOT NULL UNIQUE,
    `anidb_id`  INTEGER UNIQUE,
    PRIMARY KEY(id),
    FOREIGN KEY(`type`) REFERENCES anime_types ( type ) on delete restrict on update cascade,
    FOREIGN KEY(`status`) REFERENCES anime_statuses ( status ) on delete restrict on update cascade
)" )

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions