-
Notifications
You must be signed in to change notification settings - Fork 45
Closed
Description
Example DDL:
CREATE TABLE "participations"(
"user_id" BIGINT NOT NULL,
"project_id" BIGINT NOT NULL,
"team_id" BIGINT NOT NULL,
);
ALTER TABLE
"participations" ADD CONSTRAINT "participations_team_id_user_id_unique" UNIQUE("team_id", "user_id");
Output:
from simple_ddl_parser import DDLParser
import json
parse_results = DDLParser("""CREATE TABLE "participations"(
"user_id" BIGINT NOT NULL,
"project_id" BIGINT NOT NULL,
"team_id" BIGINT NOT NULL,
);
ALTER TABLE
"participations" ADD CONSTRAINT "participations_team_id_user_id_unique" UNIQUE("team_id", "user_id");""").run()
[
{
"table_name": "\"participations\"",
"schema": null,
"primary_key": [],
"columns": [
{
"name": "\"user_id\"",
"type": "BIGINT",
"size": null,
"references": null,
"unique": true, ------- This should probably be false
"nullable": false,
"default": null,
"check": null
},
{
"name": "\"project_id\"",
"type": "BIGINT",
"size": null,
"references": null,
"unique": false,
"nullable": false,
"default": null,
"check": null
},
{
"name": "\"team_id\"",
"type": "BIGINT",
"size": null,
"references": null,
"unique": true, ------- This should probably be false
"nullable": false,
"default": null,
"check": null
}
],
"alter": {
"uniques": [
{
"constraint_name": "\"participations_team_id_user_id_unique\"",
"columns": [
"\"team_id\"",
"\"user_id\""
]
}
]
},
"checks": [],
"index": [],
"partitioned_by": [],
"tablespace": null
}
]
It correctly identifies the composite uniques in alter.uniques. But for the individual columns, they also show "unique: true". I believe that's incorrect since there would be no way to know if the column itself has a non-composite unique index.
Looks like it's been recently fixed here: #236. Maybe the ALTER TABLE ... ADD CONSTRAINT UNQIUE were missed out there?
Metadata
Metadata
Assignees
Labels
No labels