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

[11.x] - Compare lowercased column names in getColumnType #51431

Merged
merged 1 commit into from
May 16, 2024

Conversation

chady
Copy link
Contributor

@chady chady commented May 16, 2024

I saw issue #51429 and wanted to comment that it is the responsibility of the caller to use lowercased names, but then looking at the implementation, the code already lowercases the column names it reads from the schema, so it should also be comparing them to a lowercased version of the passed in name.

@chady chady marked this pull request as ready for review May 16, 2024 15:53
@Jubeki
Copy link
Contributor

Jubeki commented May 16, 2024

How about doing the strtolower outside the loop?

$column = strtolower($column);

@chady
Copy link
Contributor Author

chady commented May 16, 2024

How about doing the strtolower outside the loop?

$column = strtolower($column);

My first thought was to do this, but I see in the same file:

if (strtolower($table) === strtolower($value['name'])) {

So I went with the same approach. I don't know how important is the performance impact on this particular method.

Additionally, I think if the lowercase needs to be applied outside the loop, it needs to introduce a new variable so that in case the column is missing, the exception message should contain the original column name and not the lowercased one.

@taylorotwell taylorotwell merged commit 74c74ec into laravel:11.x May 16, 2024
22 of 30 checks passed
@chady chady deleted the lowercase-column-name branch May 16, 2024 21:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants