Open sanyamsinghal opened 3 years ago
@sanyamsinghal can show link to steps on how to reproduce this ? What version of PostgreSQL did you compare it against ?
@ddorian I am using PostgreSQL version 11.2 for this The SQLs corresponding to this test:
DROP TABLE IF EXISTS "users" CASCADE;
CREATE TABLE IF NOT EXISTS "users" ("id" SERIAL , "objectId" VARCHAR(255) UNIQUE, "username" VARCHAR(255) UNIQUE, "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL, "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL, PRIMARY KEY ("id"));
INSERT INTO "users" ("id","username","createdAt","updatedAt") VALUES (DEFAULT,'gottlieb','2021-07-14 17:30:35.63+00','2021-07-14 17:30:35.63+00') RETURNING "id","objectId","username","createdAt","updatedAt";
START TRANSACTION;
SELECT "id", "objectId", "username", "createdAt", "updatedAt" FROM "users" AS "user" WHERE "user"."objectId" = 'asdasdasd';
CREATE OR REPLACE FUNCTION pg_temp.testfunc(OUT response "users", OUT sequelize_caught_exception text) RETURNS RECORD AS $func_1a5ff1c00a6143298db286c7f84813ef$ BEGIN INSERT INTO "users" ("id","objectId","username","createdAt","updatedAt") VALUES (DEFAULT,'asdasdasd','gottlieb','2021-07-14 17:30:41.302 +00:00','2021-07-14 17:30:41.302 +00:00') RETURNING * INTO response; EXCEPTION WHEN unique_violation THEN GET STACKED DIAGNOSTICS sequelize_caught_exception = PG_EXCEPTION_DETAIL; END $func_1a5ff1c00a6143298db286c7f84813ef$ LANGUAGE plpgsql; SELECT (testfunc.response)."id", (testfunc.response)."objectId", (testfunc.response)."username", (testfunc.response)."createdAt", (testfunc.response)."updatedAt", testfunc.sequelize_caught_exception FROM pg_temp.testfunc(); DROP FUNCTION IF EXISTS pg_temp.testfunc();
COMMIT;
(sequelize test link: https://github.com/sequelize/sequelize/blob/56bb1d6ef9827f604d7bcef945abb7e213f2322d/test/integration/model/create.test.js#L72)
Jira Link: DB-1905 This bug is found while running the Sequelize(ORM tool) test suite.
In case of UniqueConstraintError, the error message returned to Sequelize by the yugabytedb is different than that of postgres.
Error Message returned by Yugabyte:
Error Message returned by the Postgres:
The difference in: detail: undefined and detail: "Key (username)=(gottlieb) already exists." between the yugabytedb and postgres is causing the problem for Sequelize since it expects that to be defined and processing it further in its source code.