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
Property 'fieldName' option and ORM 'namingStrategy' do not affect Embeddable for MongoDB #4371
Comments
@B4nan I'm preparing PR but I'm not sure how In example , which behavior is expected?
becomes (because Profile includes Identity in
or (because root include was in
|
It should be transitive. |
This is probably a duplicate of #2165. |
Oh from #2165 it looks like the problem is also in sqlite driver, example in issue uses sqlite. I'm not sure, but may it is possible to move the responsibility of renaming from drivers to core? Now I see that driver has to check meta and correctly apply it on reads and writes. Is there a reason why core cant do renaming? |
Nope, that issue is about mongo, the reproduction was added by me as the same problem is with SQL drivers, but the fix will need to be handled on both ends. |
IIRC its done this way so its not handled twice - the query builder already handles the conversion and is used internally too. Maybe it would be best to unify this in v6. FYI there is also #2361 which is kinda connected to all of this. |
…ded properties This is breaking mainly for SQL drivers, where the default naming strategy is underscoring, and will now applied to the embedded properties too. You can restore to the old behaviour by implementing custom naming strategy, overriding the `propertyToColumnName` method. It now has a second boolean parameter to indicate if the property is defined inside a JSON object context. ```ts import { UnderscoreNamingStrategy } from '@mikro-orm/core'; class CustomNamingStrategy extends UnderscoreNamingStrategy { propertyToColumnName(propertyName: string, object?: boolean): string { if (object) { return propertyName; } return super.propertyToColumnName(propertyName, object); } } ``` Closes #4371 Closes #2165 Closes #2361
…ded properties (#4866) This is breaking mainly for SQL drivers, where the default naming strategy is underscoring, and will now applied to the embedded properties too. You can restore to the old behaviour by implementing custom naming strategy, overriding the `propertyToColumnName` method. It now has a second boolean parameter to indicate if the property is defined inside a JSON object context. ```ts import { UnderscoreNamingStrategy } from '@mikro-orm/core'; class CustomNamingStrategy extends UnderscoreNamingStrategy { propertyToColumnName(propertyName: string, object?: boolean): string { if (object) { return propertyName; } return super.propertyToColumnName(propertyName, object); } } ``` Closes #4371 Closes #2165 Closes #2361
Closing as fixed in v6 via #4866 |
…ded properties This is breaking mainly for SQL drivers, where the default naming strategy is underscoring, and will now applied to the embedded properties too. You can restore to the old behaviour by implementing custom naming strategy, overriding the `propertyToColumnName` method. It now has a second boolean parameter to indicate if the property is defined inside a JSON object context. ```ts import { UnderscoreNamingStrategy } from '@mikro-orm/core'; class CustomNamingStrategy extends UnderscoreNamingStrategy { propertyToColumnName(propertyName: string, object?: boolean): string { if (object) { return propertyName; } return super.propertyToColumnName(propertyName, object); } } ``` Closes #4371 Closes #2165 Closes #2361
…ded properties (#4866) This is breaking mainly for SQL drivers, where the default naming strategy is underscoring, and will now applied to the embedded properties too. You can restore to the old behaviour by implementing custom naming strategy, overriding the `propertyToColumnName` method. It now has a second boolean parameter to indicate if the property is defined inside a JSON object context. ```ts import { UnderscoreNamingStrategy } from '@mikro-orm/core'; class CustomNamingStrategy extends UnderscoreNamingStrategy { propertyToColumnName(propertyName: string, object?: boolean): string { if (object) { return propertyName; } return super.propertyToColumnName(propertyName, object); } } ``` Closes #4371 Closes #2165 Closes #2361
…ded properties (#4866) This is breaking mainly for SQL drivers, where the default naming strategy is underscoring, and will now applied to the embedded properties too. You can restore to the old behaviour by implementing custom naming strategy, overriding the `propertyToColumnName` method. It now has a second boolean parameter to indicate if the property is defined inside a JSON object context. ```ts import { UnderscoreNamingStrategy } from '@mikro-orm/core'; class CustomNamingStrategy extends UnderscoreNamingStrategy { propertyToColumnName(propertyName: string, object?: boolean): string { if (object) { return propertyName; } return super.propertyToColumnName(propertyName, object); } } ``` Closes #4371 Closes #2165 Closes #2361
…ded properties (#4866) This is breaking mainly for SQL drivers, where the default naming strategy is underscoring, and will now applied to the embedded properties too. You can restore to the old behaviour by implementing custom naming strategy, overriding the `propertyToColumnName` method. It now has a second boolean parameter to indicate if the property is defined inside a JSON object context. ```ts import { UnderscoreNamingStrategy } from '@mikro-orm/core'; class CustomNamingStrategy extends UnderscoreNamingStrategy { propertyToColumnName(propertyName: string, object?: boolean): string { if (object) { return propertyName; } return super.propertyToColumnName(propertyName, object); } } ``` Closes #4371 Closes #2165 Closes #2361
Describe the bug
Use MongoDB driver
Use
@Property({fieldName: 'something'})
in embedded entity or choose UnderscoreNamingStrategy for ORMIn database embedded entity will have same naming as in code.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Renaming should propagate to the depth of embedded documents.
Versions
The text was updated successfully, but these errors were encountered: