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

feat(core): add support for entity and property comment #668

Merged
merged 3 commits into from Jul 18, 2020
Merged

feat(core): add support for entity and property comment #668

merged 3 commits into from Jul 18, 2020

Conversation

vinverdy
Copy link
Contributor

@vinverdy vinverdy commented Jul 18, 2020

Closes: #649

@B4nan
Copy link
Member

B4nan commented Jul 18, 2020

Looking good. Please use it in some of the existing entities we have in tests to verify it is working (for that we can leverage the existing schema generator tests, the difference will be visible in their snapshots).

packages/knex/src/schema/SchemaGenerator.ts Outdated Show resolved Hide resolved
@@ -382,6 +386,7 @@ export class SchemaGenerator {
Utils.runIfNotEmpty(() => col.index(indexName), index);
Utils.runIfNotEmpty(() => col.unique(uniqueName), prop.unique);
Utils.runIfNotEmpty(() => col.defaultTo(prop.defaultRaw ? this.knex.raw(prop.defaultRaw) : null), !sameDefault);
Utils.runIfNotEmpty(() => col.comment(columnComment), columnComment);
Copy link
Member

@B4nan B4nan Jul 18, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be enough (if its falsy, we won't use the value anyway)

Suggested change
Utils.runIfNotEmpty(() => col.comment(columnComment), columnComment);
Utils.runIfNotEmpty(() => col.comment(prop.comment!), prop.comment);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment(value: string): ColumnBuilder;

it fail there, because knex expect a string cannot accept undefined, so what should i do?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that is just TS warning, using prop.comment! should work

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah okay, I just want to follow your convention

@B4nan B4nan mentioned this pull request Jul 18, 2020
46 tasks
@vinverdy
Copy link
Contributor Author

ok thanks for your feedback, i will update soon

@vinverdy
Copy link
Contributor Author

I already update as you requested

tests/entities-sql/Address2.ts Outdated Show resolved Hide resolved
tests/entities-sql/Address2.ts Outdated Show resolved Hide resolved
packages/knex/src/schema/SchemaGenerator.ts Outdated Show resolved Hide resolved
@B4nan
Copy link
Member

B4nan commented Jul 18, 2020

Ok, looking good now, let's wait for the green light from CI :]

tests/__snapshots__/SchemaGenerator.test.ts.snap Outdated Show resolved Hide resolved
tests/__snapshots__/SchemaGenerator.test.ts.snap Outdated Show resolved Hide resolved
tests/__snapshots__/SchemaGenerator.test.ts.snap Outdated Show resolved Hide resolved
tests/__snapshots__/SchemaGenerator.test.ts.snap Outdated Show resolved Hide resolved
tests/__snapshots__/SchemaGenerator.test.ts.snap Outdated Show resolved Hide resolved
tests/__snapshots__/SchemaGenerator.test.ts.snap Outdated Show resolved Hide resolved
@B4nan B4nan merged commit 45af255 into mikro-orm:dev Jul 18, 2020
@B4nan
Copy link
Member

B4nan commented Jul 18, 2020

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants