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

Model Generator failed to generate relation function name in camelcase format when column-name in the database is uppercase #325

Open
adipriyantobpn opened this issue Dec 26, 2017 · 9 comments
Labels
status:ready for adoption Feel free to implement this issue. type:enhancement Enhancement

Comments

@adipriyantobpn
Copy link
Contributor

What steps will reproduce the problem?

Column name in the database table is in uppercase format, eg. CUSTOMER_COUNTRY_ID

What's expected?

Generate relation function : public function getCustomerCountry() {...}

What do you get instead?

Relation function will be generated as : public function getCUSTOMERCOUNTRY() {...}

Additional info

Q A
Yii version 2.0.13.1
PHP version 7.1
Operating system Centos 7
@samdark
Copy link
Member

samdark commented Dec 26, 2017

Hmm... how should gii behave if the table name is customer_SSID?

@adipriyantobpn
Copy link
Contributor Author

I think it's better to be generated into getCustomerSsid, then.
Or maybe is there any other better format?

@samdark
Copy link
Member

samdark commented Dec 26, 2017

I'd expect it to be getCustomerSSID.

@adipriyantobpn
Copy link
Contributor Author

Hmmm.. if i may ask your opinion, how about CUSTOMER_SSID?
Which one that should look better, getCustomerSsid or getCUSTOMERSSID? :)

@samdark
Copy link
Member

samdark commented Dec 26, 2017

That's the problem. DB conventions may be different. Either we should introduce different schemas to select or not to change current behavior.

@adipriyantobpn
Copy link
Contributor Author

Agreed..

Hmm.. Is there a way to customize the current behavior? Or maybe any plan to provide a way to customize it?

For example:
If the column-name is in lower-case, current camelizing behavior is just fine.
If it is in upper-case, we can set generated string to be camelized after it is turned to lowercase first.
If it is in mixed-case, only first character is turned to uppercase (in this case, i just tested that current behavior is working just as expected).

For the sake of clean function naming though.

@samdark
Copy link
Member

samdark commented Dec 26, 2017

Agree. It makes sense the way you've described it.

@samdark samdark added status:ready for adoption Feel free to implement this issue. type:enhancement Enhancement and removed status:under discussion labels Dec 26, 2017
@rob006
Copy link
Contributor

rob006 commented Dec 26, 2017

I'd expect it to be getCustomerSSID.

If you expect getCustomerSSID your column should be named customer_S_S_I_D_id. getCustomerSsid looks perfectly valid for me.

@sdlins
Copy link
Contributor

sdlins commented Jun 13, 2018

This is very similar to #366. But there we have a new form option to enable PSR names. It was not set default for BC. Should it be done here too? I mean, should we have a optional feature or should it be default? I fear to have too much options in gii model generator form.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:ready for adoption Feel free to implement this issue. type:enhancement Enhancement
Projects
None yet
Development

No branches or pull requests

4 participants