Skip to content

Invalid CREATE TABLE and CREATE INDEX SQL #5

@ignatz

Description

@ignatz

Reported by a user on reddit (https://www.reddit.com/r/selfhosted/comments/1grf3m8/comment/lxb2m0z/?context=3):


    Once I can see the foreign key, it cannot create the link (due to syntax error), and looking at the generated SQL it isn't valid:

     CREATE TABLE todos2 (
       id BLOB PRIMARY KEY CHECK(is_uuid_v7(id)) DEFAULT (uuid_v7()) NOT NULL,
       user BLOB DEFAULT '' FOREIGN KEY(user) REFERENCES _user(id),
       name TEXT NOT NULL
     ) STRICT;

but it should be the following (FOREIGN KEY syntax isn't valid in SQLIte I believe) :

CREATE TABLE todos2 (
  id BLOB PRIMARY KEY DEFAULT (uuid_v7()) CHECK (is_uuid_v7(id)) NOT NULL,
  user BLOB DEFAULT '' REFERENCES _user(id),
  name TEXT NOT NULL
) STRICT;

    Similarly, creating an index (just including the id column) gives an error related to JSON and the missing field "if_not_exists".

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