-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Add support to have lower case properites via a config variable. #1215
Conversation
|
I have reverted the style changes. I have looked into the hooks but I cannot see a way to change the case of the column name, as the hooks seem to be for adding additional information. |
What I don't understand so far: is this a technical or cosmetic change? ide helper just provides convenient IDE assistance, what is the different on |
It's a bit of both. When using the https://github.com/yajra/laravel-oci8 library, it returns the properties lower case by default. Although it can be overridden, I prefer the lower case properties. So, $model->COLUMN works if I manually set the properties to upper case, and $model->column works when using the default. The issue is for methods. If using the default of uppercase, calling wherePAGENUMBER($value) results in the error: ORA-00904: "P_A_G_E_N_U_M_B_E_R": invalid identifier Where as if the property is lower case, as wherePageNumber($value), it works properly. Please, let me know if you have any further questions. |
So this config change only makes sense together with https://github.com/yajra/laravel-oci8 ? Just so I get this correct Using regular oci8:
Using laravel-oci8:
Unrelated to this, I don't think this should be enabled by default. And since you mentioned Oracle explicitly in the config documentation, I think it's fair to mention laravel-oci8 , as it seems to be required anyway for a sane integration. Is this correct so far? |
Yes it should be defaulted to false, I have fixed the config file.
Does this make sense? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went once more through the PR and from my side, I'm ok with the general goal.
Looked now a bit closer and left some inline feedback, i.e. in the current version of the PR you accidentally removed hasLowerCaseProperties()
so it doesn't really work.
Some other feedback: I appreciate you fixing the code style back, but it really doesn't make sense to keep your first commit like that. I ask you kindly if you can in the end just rebase and clean this up with a single proper commit; please also update against latest master in the meantime.
Lastly, please also add a changelog entry and see if you find a good spot in the README to mention the new config.
Thank you!
config/ide-helper.php
Outdated
|-------------------------------------------------------------------------- | ||
| Some databases, like Oracle return the column names in upper case | ||
| | ||
| For example, normally you would see this: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| For example, normally you would see this: | |
| For example, normally with Oracle you would see this: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated doc block with your suggestion.
src/Console/ModelsCommand.php
Outdated
@@ -442,6 +442,11 @@ public function getPropertiesFromTable($model) | |||
|
|||
foreach ($columns as $column) { | |||
$name = $column->getName(); | |||
|
|||
if ($this->hasLowerCaseProperties()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something got b0rked with your last change, the method hasLowerCaseProperties
isn't present anymore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Re-added the missing function
$app['config']->set('ide-helper.model_lower_case_properties', true); | ||
} | ||
|
||
public function test(): void |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test doesn't really perform the test you intended it to do, because none of the migrations provide upper case column definitions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added proper tests by creating column names that are uppercase
d095736
to
2fa2b3a
Compare
Rebased and updated Changelog. I didn't find a good spot in the readme. |
src/Console/ModelsCommand.php
Outdated
use Doctrine\DBAL\Exception as DBALException; | ||
use Doctrine\DBAL\Types\Type; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These lines should not be removed 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry about that. I put the missing lines back.
…mn names are upper case
2fa2b3a
to
7e9800b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Ping @barryvdh , from my side good to merge
use Illuminate\Console\Command; | ||
use Doctrine\DBAL\Exception as DBALException; | ||
use Doctrine\DBAL\Types\Type; | ||
use Illuminate\Console\Command; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:sadpanda:
but fix-style will correct this, so nothing to do
Summary
Allow column properties to be transformed to lower case via a configuration variable.
Type of change
Checklist
composer fix-style