Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
lundibundi opened this issue Oct 16, 2021 · 3 comments
Open
Labels
bug Something isn't working

Comments

@lundibundi
Copy link
Member

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 [email protected] + [email protected]

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

@lundibundi lundibundi added the bug Something isn't working label Oct 16, 2021
@georgolden
Copy link
Member

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

@lundibundi lundibundi transferred this issue from metarhia/metaschema Jun 14, 2022
@lundibundi
Copy link
Member Author

@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.

@georgolden
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants