Entering a row referencing a uuid column
How do I enter a row in the editor that references a different table with a UUID as key?
I'm using H2 and have two tables:
CREATE TABLE COMPANIES (
ID UUID DEFAULT RANDOM_UUID() PRIMARY KEY,
NAME VARCHAR(255) NOT NULL
);
and
CREATE TABLE USERS (
EMAIL VARCHAR(255) PRIMARY KEY,
PASSWORD VARCHAR(255) NOT NULL,
COMPANY UUID NOT NULL,
FOREIGN KEY (COMPANY) REFERENCES COMPANIES (ID)
);
When I try to manually enter a new column in the USERS table and paste a valid company id into column COMPANY it gives me a reference error. Perhaps because the entered string isn't cast to a UUID? I'm very sure I entered a valid id from COMPANY.
INSERT INTO "PUBLIC"."USERS" ("EMAIL", "PASSWORD", "COMPANY") VALUES (?, ?, ?);
[23506][23506] Referential integrity constraint violation: "CONSTRAINT_4D: PUBLIC.USERS FOREIGN KEY(COMPANY) REFERENCES PUBLIC.COMPANIES(ID) ('36343861-3366-3832-2d36-3531312d3436')"; SQL statement:
INSERT INTO "PUBLIC"."USERS" ("EMAIL", "PASSWORD", "COMPANY") VALUES (?, ?, ?) [23506-192]
Please sign in to leave a comment.
I don't think that WebStorm forum is the right place for such questions; if you need an answer, please try asking it at StackOverflow
Shit, I'm using Datagrip... posted in the wrong forum. Sorry.
But WebStorm provides absolutely no DB/SQL support