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

Fix handling of null columns in PostgresProcessor processIndexes. #53936

Closed
securit opened this issue Dec 17, 2024 · 2 comments · Fixed by #53945
Closed

Fix handling of null columns in PostgresProcessor processIndexes. #53936

securit opened this issue Dec 17, 2024 · 2 comments · Fixed by #53945

Comments

@securit
Copy link

securit commented Dec 17, 2024

Laravel Version

11.35.1

PHP Version

8.3.14

Database Driver & Version

8.3.14

Description

Previously, null values in the columns field caused issues during the explode operation. This fix ensures that explode is only called when columns is not null, preventing potential errors, depreaction warnings and improving data consistency.

Background:

When indexes are created with an expression, Indexes on Expressions rather than a table column, php raises a deprecation warning message LOG.warning: explode(): Passing null to parameter #2 ($string) of type string is deprecated in vendor/laravel/framework/src/Illuminate/Database/Query/Processors/PostgresProcessor.php on line 127

This is particularly evident when using indexes based on expressions rather than indexes based on a table column. An example of why you would want to do this might be indexing based upon an aggregation of the year in a timestamp field.

$table->rawIndex("DATE_TRUNC('year'::text,created_at)", 'radar_records_created_at_trunc_year_idx');

Steps To Reproduce

Create a table in a migration with a functional index

Schema::table('test_records', static function (Blueprint $table) {
            $table->index('id');
            $table->timestamps();
            $table->rawIndex("DATE_TRUNC('year'::text,created_at)", 'test_records_created_at_trunc_year_idx');

Create a call to get indexes

$schema=DB::connection()->getSchemaBuilder();
$indexes = $schema->getIndexes('test_records');
@securit
Copy link
Author

securit commented Dec 17, 2024

Pull request raised #53937

Copy link

Thank you for reporting this issue!

As Laravel is an open source project, we rely on the community to help us diagnose and fix issues as it is not possible to research and fix every issue reported to us via GitHub.

If possible, please make a pull request fixing the issue you have described, along with corresponding tests. All pull requests are promptly reviewed by the Laravel team.

Thank you!

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

Successfully merging a pull request may close this issue.

2 participants