Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upproblem parsing check constraint table definition #1454
Comments
justinclift
added
the
help wanted
label
Jun 29, 2018
This comment has been minimized.
This comment has been minimized.
|
Thanks for the report and the detailed analysis, @eyeteajay! This is a problem in our grammar parser. We detect these sort of issues (which is why you get that warning) and fall back to a simpler approach. That's why you can still browse the table. But for other features and especially for editing the table there just isn't enough information this way. Anyway, I'll have a closer look at the problem now |
MKleusberg
added
bug
and removed
help wanted
labels
Jul 10, 2018
MKleusberg
self-assigned this
Jul 10, 2018
added a commit
that referenced
this issue
Jul 10, 2018
This comment has been minimized.
This comment has been minimized.
|
I believe the issue is fixed now |
MKleusberg
added
the
response requested
label
Jul 12, 2018
This comment has been minimized.
This comment has been minimized.
parno
commented
Jul 30, 2018
•
|
FWIW, I'm seeing a similar issue with this (simplified) table definition:
I was able to create it via the UI, but the parser seems to struggle with it, even with today's (7/29) nightly build. I'm running on Mac OS X, 10.13.5. |
This comment has been minimized.
This comment has been minimized.
|
I tested with the queries in this issue. The first one couldn't be parsed until I removed the DEFAULT clauses: CREATE TABLE "AssetTreeAssoc4" (
uuid BINARY(16) NOT NULL,
cdt DATETIME, -- DEFAULT (DATETIME('NOW')) NOT NULL,
mdt DATETIME, -- DEFAULT (DATETIME('NOW')) NOT NULL,
"passetID" INTEGER NOT NULL,
"cassetID" INTEGER NOT NULL,
depth INTEGER DEFAULT 0 NOT NULL,
id INTEGER NOT NULL,
PRIMARY KEY (id),
CONSTRAINT "ck_AssetTreeAssoc_depth" CHECK ((passetID <> cassetID and depth > 1) or depth == 0),
CONSTRAINT "uq_AssetTreeAssoc" UNIQUE ("cassetID", depth),
FOREIGN KEY("passetID") REFERENCES "AssetTree" (id) ON DELETE CASCADE,
FOREIGN KEY("cassetID") REFERENCES "AssetTree" (id) ON DELETE CASCADE
)The second one has problems too. It worked when one side of the OR condition is entirely removed: CREATE TABLE "Transactions3" (
"stock_id" INTEGER CHECK(
stock_id is null AND shares is null),
-- OR
-- (stock_id is not null AND shares is not null)),
"shares" INTEGER
);Removing the internal parenthesis is also parseable (of course, I'm not proposing this as a workaround): CREATE TABLE "Transactions4" (
"stock_id" INTEGER CHECK(
stock_id is null AND shares is null
OR
stock_id is not null AND shares is not null),
"shares" INTEGER
); |
mgrojo
added
SQL
and removed
response requested
labels
Oct 8, 2018
This comment has been minimized.
This comment has been minimized.
moll
commented
Dec 1, 2018
|
Also seeing the same here with v3.11.0-beta1 and the following schema: CREATE TABLE initiatives (
uuid STRING PRIMARY KEY NOT NULL,
mailchimp_interest_id STRING NOT NULL UNIQUE,
notes TEXT NOT NULL DEFAULT "",
CONSTRAINT initiatives_uuid_length
CHECK (length(uuid) == 36),
CONSTRAINT initiatives_mailchimp_interest_id
CHECK (length(mailchimp_interest_id) > 0)
);
|
eyeteajay commentedJun 29, 2018
•
edited
Under the table definition, there is a warning that says: "There is something wrong with this table definition that our parser doesn't fully understand." Also, the table cannot be expanded in the "database structure panel". However, the program seems to work and read the rows anyway.
Details for the issue
The problem is with ck_AssetTreeAssoc_depth, because the table definition can be parsed fine without it. My guess would be the nested parenthesis? The problem DDL is:
Useful extra information
The info below often helps, please fill it out if you're able to. :)
What operating system are you using?
What is your DB4S version?
Did you also