Duplicate `id` in column name upon declaring a reference to `Identifier`
lundibundi opened this issue · 3 comments
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
It is not clear for me now. For schema it will work as a reference to identifier. See https://github.com/metarhia/metaschema/blob/6e07922de1afb5a28429895e05f9cc0359895a9c/test/model.js#L104-#L137
It is mostly related to metasql
. So if I understood correctly we must have property id -> { reference: Identifier }
. It works like this in schema now
@georgolden yep, wrong repo, moved to metasql now.
Though for metaschema there is still an issue with d.ts
types which are not generated according to the cases here. Though it probably means that we have to move types generation here as well.
Yeah, there was and there are still some issues with type generation, but typings are not for metasql. It can be done, after we will meet agreement on current changes. We don't have an agreement about current implementation. I improved code quality, and we have no guidelines for static and private fields, and it's usage, so there can be even more refactoring within the current metaschema 2.0.0-alpha