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] Fix type mismatch in Polymorphic Relationships When Using PostgreSQL #54414

Draft
wants to merge 27 commits into
base: 11.x
Choose a base branch
from

Conversation

crynobone
Copy link
Member

@crynobone crynobone commented Jan 30, 2025

fixes #54401

The changes introduce a "string" default morph type via schema and eloquent relationship.

Global

To combine uuid or ulid with int globally.

Illuminate\Database\Schema\Builder::defaultMorphKeyType('string');

Per relationship

Alternatively, you can manually set it per table using either $table->nullableStringableMorphs('owner') or $table->stringableMorphs('owner') method.

Next, define the relationship using:

public function integrations()
{
    return $this->morphMany(Owner::class, 'owner', morphKeyType: 'string');
}

or

public function integrations()
{
    return $this->morphMany(Owner::class, 'owner')->morphKeyType('string');
}

crynobone and others added 21 commits January 31, 2025 21:06
Signed-off-by: Mior Muhammad Zaki <[email protected]>
Signed-off-by: Mior Muhammad Zaki <[email protected]>
Signed-off-by: Mior Muhammad Zaki <[email protected]>
Signed-off-by: Mior Muhammad Zaki <[email protected]>
Signed-off-by: Mior Muhammad Zaki <[email protected]>
* wip

* Apply fixes from StyleCI

* wip

* wip

---------

Co-authored-by: StyleCI Bot <[email protected]>
Co-authored-by: Mior Muhammad Zaki <[email protected]>
Signed-off-by: Mior Muhammad Zaki <[email protected]>
Signed-off-by: Mior Muhammad Zaki <[email protected]>
Signed-off-by: Mior Muhammad Zaki <[email protected]>
Signed-off-by: Mior Muhammad Zaki <[email protected]>
Signed-off-by: Mior Muhammad Zaki <[email protected]>
Signed-off-by: Mior Muhammad Zaki <[email protected]>
@crynobone crynobone changed the title Fix Type Mismatch in Polymorphic Relationships When Using PostgreSQL [11.x] Fix type mismatch in Polymorphic Relationships When Using PostgreSQL Apr 7, 2025
@crynobone crynobone marked this pull request as ready for review April 7, 2025 03:09
crynobone and others added 5 commits April 7, 2025 19:03
Signed-off-by: Mior Muhammad Zaki <[email protected]>
Signed-off-by: Mior Muhammad Zaki <[email protected]>
Signed-off-by: Mior Muhammad Zaki <[email protected]>
Signed-off-by: Mior Muhammad Zaki <[email protected]>
@taylorotwell taylorotwell marked this pull request as draft April 7, 2025 21:23
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.

Type Mismatch in Polymorphic Relationships When Using PostgreSQL
3 participants