Skip to content

Duplicate id in column name upon declaring a reference to Identifier #237

Description

@lundibundi

Describe the bug
id will be unconditionally added (and duplicated) in field (table column) name upon declaring it with id in name.

To Reproduce

({
  Registry: {},

  id: '?Identifier',
});

Actual behavior

Resulting table contains idId column:

CREATE TABLE "Table" (
  "idId" bigint NULL,
...
)
...
ALTER TABLE "Table" ADD CONSTRAINT "fkTableId" FOREIGN KEY ("id") REFERENCES "Identifier" ("id");

Expected behavior
Resulting table contains name= id column.

Suggested solution
Only add id to name if it doesn't already have it. Meaning that

identifier => identifier
id => id
link => linkId
name => nameId 

Additional context
Using latest impress@2.6.6 + metaschema@1.3.4

See https://github.com/metarhia/metaschema/blob/master/lib/schema.js#L287-L299

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions