yii2-gii
yii2-gii copied to clipboard
Model Generator failed to generate relation function name in camelcase format when column-name in the database is uppercase
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 |
Hmm... how should gii behave if the table name is customer_SSID?
I think it's better to be generated into getCustomerSsid, then. Or maybe is there any other better format?
I'd expect it to be getCustomerSSID.
Hmmm.. if i may ask your opinion, how about CUSTOMER_SSID?
Which one that should look better, getCustomerSsid or getCUSTOMERSSID? :)
That's the problem. DB conventions may be different. Either we should introduce different schemas to select or not to change current behavior.
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.
Agree. It makes sense the way you've described it.
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.
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.