From 5f25ad2bb09edd4594fb6c391035e9783e2a0b6b Mon Sep 17 00:00:00 2001 From: "Fabian @ Blax Software" Date: Wed, 10 Jun 2026 11:27:33 +0200 Subject: [PATCH] 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: ' (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. --- src/Models/PermissionMember.php | 10 ++++++++++ src/Models/RoleMember.php | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/Models/PermissionMember.php b/src/Models/PermissionMember.php index 95e3aba..59a14e2 100644 --- a/src/Models/PermissionMember.php +++ b/src/Models/PermissionMember.php @@ -19,6 +19,16 @@ class PermissionMember extends MorphPivot ]; 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: ''" (error 1292) the + // moment a UUID-keyed member shares the same permission. + 'member_id' => 'string', 'context' => 'array', 'expires_at' => 'datetime', ]; diff --git a/src/Models/RoleMember.php b/src/Models/RoleMember.php index 4187a7d..a72e8e8 100644 --- a/src/Models/RoleMember.php +++ b/src/Models/RoleMember.php @@ -20,6 +20,16 @@ class RoleMember extends MorphPivot ]; 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: ''" (error 1292) the + // moment a UUID-keyed member shares the same role. + 'member_id' => 'string', 'context' => 'array', 'expires_at' => 'datetime', 'created_at' => 'datetime',