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

Numbers in a string using underscore naming strategy #7855

Closed
vuras opened this issue Oct 8, 2019 · 12 comments
Closed

Numbers in a string using underscore naming strategy #7855

vuras opened this issue Oct 8, 2019 · 12 comments
Assignees
Labels
Milestone

Comments

@vuras
Copy link

vuras commented Oct 8, 2019

Bug Report

Q A
BC Break no
Version 2.6.4

Summary

If a string has numbers the naming strategy fails to convert the property name.

Current behavior

base64Encoded converts to base64encoded

How to reproduce

Add a property to entity that has a number in camelcased property name.

Expected behavior

base64Encoded converts to base64_encoded

@Ocramius
Copy link
Member

Ocramius commented Oct 8, 2019

Possibly a bug in https://github.com/doctrine/inflector?

@lcobucci
Copy link
Member

lcobucci commented Oct 8, 2019

Not really:

private function underscore($string)
{
$string = preg_replace('/(?<=[a-z])([A-Z])/', '_$1', $string);
if ($this->case === CASE_UPPER) {
return strtoupper($string);
}
return strtolower($string);
}

@lcobucci
Copy link
Member

lcobucci commented Oct 8, 2019

Seems an easy pick, though

@Ocramius
Copy link
Member

Ocramius commented Oct 8, 2019

Was totally convinced it would be using the inflector there :D

@vuras feel free to send a patch (and test) for UnderscoreNamingStrategy

@lcobucci
Copy link
Member

lcobucci commented Oct 8, 2019

Sorry, I got the patch already 😬

There's just one problem, though: it affects table names like DDC1476EntityWithDefaultFieldType (which gets converted to DDC1476_ENTITY_WITH_DEFAULT_FIELD_TYPE instead of DDC1476ENTITY_WITH_DEFAULT_FIELD_TYPE).

Possible BC break, then, so I'll force it to only work for properties.

@lcobucci
Copy link
Member

lcobucci commented Oct 8, 2019

Handled by #7856, thanks for reporting it @vuras!

@lcobucci lcobucci closed this as completed Oct 8, 2019
@vuras
Copy link
Author

vuras commented Oct 8, 2019

Thank you! When should I expect the 2.6.5 released?

@lcobucci
Copy link
Member

lcobucci commented Oct 8, 2019

I'd like to say "really soon" but, realistically speaking, it should take us a few weeks since there're some bugs that should be included IMHO.

@igoel
Copy link

igoel commented Nov 18, 2019

Sorry, I got the patch already

There's just one problem, though: it affects table names like DDC1476EntityWithDefaultFieldType (which gets converted to DDC1476_ENTITY_WITH_DEFAULT_FIELD_TYPE instead of DDC1476ENTITY_WITH_DEFAULT_FIELD_TYPE).

Possible BC break, then, so I'll force it to only work for properties.

Even this, is breaking everything, so why do this in a minor version?

@lcobucci
Copy link
Member

@igoel @cobyl @sGy1980de we overlooked things and this is indeed a BC break. I'll rework it and send a new patch version 2.6.6 to address that.

I'm sorry for affecting your app and thank you for letting us know of this error.

@lcobucci
Copy link
Member

@igoel @cobyl @sGy1980de new release made to address the BC break. We apologise, again, for the inconvenience.

@igoel
Copy link

igoel commented Nov 19, 2019

Thx, for the fast response and action 👍

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

No branches or pull requests

4 participants