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

fix(entity-generator): use table name instead of class name in EntitySchema #3916

Merged
merged 6 commits into from Jan 8, 2023
Merged

Conversation

koneru9999
Copy link
Contributor

@koneru9999 koneru9999 commented Jan 6, 2023

Closes #3915

@koneru9999 koneru9999 changed the title Use table name in EntitySchema instead of entity class name fix(core): Use table name in EntitySchema instead of entity class name Jan 6, 2023
@koneru9999 koneru9999 changed the title fix(core): Use table name in EntitySchema instead of entity class name fix(#3915): Use table name in EntitySchema instead of entity class name Jan 6, 2023
@@ -42,7 +42,7 @@ export class EntitySchemaSourceFile extends SourceFile {
ret += ` class: ${this.meta.className},\n`;

if (this.meta.collection !== this.namingStrategy.classToTableName(this.meta.className)) {
ret += ` tableName: ${this.quote(this.meta.className)},\n`;
ret += ` tableName: ${this.quote(this.meta.tableName)},\n`;
Copy link
Member

Choose a reason for hiding this comment

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

meta.tableName is an alias for meta.collection, i'd like to use the same in the condition on line 44 as well, to reduce confusion. i dont mind using meta.tableName on both places

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks. applied the same check at L44 now.

@@ -151,6 +151,23 @@ describe('EntityGenerator', () => {
await orm.close(true);
});

test('table name with underscore using entitySchema [mysql]', async () => {
const orm = await initORMMySql('mysql', {entityGenerator: {
Copy link
Member

Choose a reason for hiding this comment

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

is this passing the linter? :] i dont think so, the indents on following lines are also wrong

Suggested change
const orm = await initORMMySql('mysql', {entityGenerator: {
const orm = await initORMMySql('mysql', { entityGenerator: {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

true that. i didn't run lint from my local

@koneru9999 koneru9999 marked this pull request as ready for review January 8, 2023 09:47
@B4nan B4nan changed the title fix(#3915): Use table name in EntitySchema instead of entity class name fix(entity-generator): use table name instead of class name in EntitySchema Jan 8, 2023
@codecov-commenter
Copy link

codecov-commenter commented Jan 8, 2023

Codecov Report

Base: 99.80% // Head: 99.80% // No change to project coverage 👍

Coverage data is based on head (c8ea6e6) compared to base (055913e).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #3916   +/-   ##
=======================================
  Coverage   99.80%   99.80%           
=======================================
  Files         214      214           
  Lines       13651    13651           
  Branches     3189     3189           
=======================================
  Hits        13625    13625           
  Misses         24       24           
  Partials        2        2           
Impacted Files Coverage Δ
...ges/entity-generator/src/EntitySchemaSourceFile.ts 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@B4nan B4nan merged commit 84d9407 into mikro-orm:master Jan 8, 2023
@B4nan
Copy link
Member

B4nan commented Jan 8, 2023

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.

Incorrect table mapping when using EntityGenerator with entitySchema
3 participants