ihp icon indicating copy to clipboard operation
ihp copied to clipboard

IHP does not understand SQL column constraints

Open jchia opened this issue 4 years ago • 0 comments

The following table definition in Schema.hs is not recognized by IHP:

CREATE TABLE posts (
    id UUID DEFAULT uuid_generate_v4() PRIMARY KEY NOT NULL,
    title TEXT NOT NULL,
    body TEXT NOT NULL CHECK (body <> ''),
    created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW() NOT NULL
);

The error message is:

Application/Schema.sql:5:24:
  |
5 |     body TEXT NOT NULL CHECK (body <> ''),
  |                        ^
unexpected 'C'
expecting "UNIQUE", ')', or ','

The following table definition is recognized:

-- Your database schema. Use the Schema Designer at http://localhost:8001/ to add some tables.
CREATE TABLE posts (
    id UUID DEFAULT uuid_generate_v4() PRIMARY KEY NOT NULL,
    title TEXT NOT NULL,
    body TEXT NOT NULL,
    CHECK (body <> ''),
    created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW() NOT NULL
);

Apparently, IHP understands table constraints but not column constraints.

jchia avatar Oct 10 '21 10:10 jchia