Skip to content
This repository was archived by the owner on Jan 7, 2025. It is now read-only.
This repository was archived by the owner on Jan 7, 2025. It is now read-only.

Model save not casting UUID to binary? #55

@schmoove

Description

@schmoove

Thank you for the great package. I'm struggling with a persisting issue and wondering what I'm missing.
If I simply load a record from a model, change a property, and then save it, I get this exception:

b"SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'template_id' at row 1 (SQL: update documentsettemplate_id= fb3c3189-9e96-4283-98e2-f5f8e114370c,document.updated_at= 2022-03-10 20:48:38 whereid = §\x15cÍõ8M>Åeì¯k╗╚e)"

So the id is being cast correctly, but not the template_id. Thanks for your help.

Model:

public function uuidColumns(): array
    {
        return ['id', 'template_id'];
    }

protected $casts = [
        'id' => EfficientUuid::class,
        'template_id' => EfficientUuid::class
    ];

Controller:

$document = Document::whereUuid($id, 'id')->first();
$document->status = 'CANCELLED';
        try {
            $document->save();
        } catch (\Exception $e){
            dd($e->getMessage());
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions