fix: cast pivot member_id to string (avoid MySQL DOUBLE coercion)

RoleMember/PermissionMember.member_id is a polymorphic varchar(36) holding either a UUID (HasUuids host models) or a stringified bigint (auto-increment host models). Without a string cast, a bigint member key binds as an INTEGER and MySQL coerces the whole varchar column to DOUBLE to compare, throwing 'Truncated incorrect DOUBLE value: <uuid>' (1292) the moment a UUID-keyed member shares the same role/permission. Casting member_id to string binds it as a string in every attach/detach/where. Package suite 162 green.
This commit is contained in:
Fabian @ Blax Software 2026-06-10 11:27:33 +02:00
parent 23424bbe2a
commit 5f25ad2bb0
2 changed files with 20 additions and 0 deletions

View File

@ -19,6 +19,16 @@ class PermissionMember extends MorphPivot
]; ];
protected $casts = [ protected $casts = [
// member_id is a polymorphic varchar(36) that holds either a UUID
// (HasUuids host models) or a stringified bigint (auto-increment
// host models, e.g. a default User). Casting to string forces the
// value to be bound as a string in every query Eloquent builds for
// this pivot (attach / detach / where). Without it a bigint member
// key is bound as an INTEGER, and MySQL then coerces the WHOLE
// varchar column to DOUBLE to compare — which throws
// "Truncated incorrect DOUBLE value: '<uuid>'" (error 1292) the
// moment a UUID-keyed member shares the same permission.
'member_id' => 'string',
'context' => 'array', 'context' => 'array',
'expires_at' => 'datetime', 'expires_at' => 'datetime',
]; ];

View File

@ -20,6 +20,16 @@ class RoleMember extends MorphPivot
]; ];
protected $casts = [ protected $casts = [
// member_id is a polymorphic varchar(36) that holds either a UUID
// (HasUuids host models) or a stringified bigint (auto-increment
// host models, e.g. a default User). Casting to string forces the
// value to be bound as a string in every query Eloquent builds for
// this pivot (attach / detach / where). Without it a bigint member
// key is bound as an INTEGER, and MySQL then coerces the WHOLE
// varchar column to DOUBLE to compare — which throws
// "Truncated incorrect DOUBLE value: '<uuid>'" (error 1292) the
// moment a UUID-keyed member shares the same role.
'member_id' => 'string',
'context' => 'array', 'context' => 'array',
'expires_at' => 'datetime', 'expires_at' => 'datetime',
'created_at' => 'datetime', 'created_at' => 'datetime',