I just upgraded an existing app from OC v2 to OC v3.
I have a model using the trait
encryptable that defines the field
email as encryptable.
With OC v2, it saves appropriately, but with OC v3 I have this error:
SQLSTATE: String data, right truncated: 1406 Data too long for column 'email' at row 1
'name' => 'John Does',
'email' => 'firstname.lastname@example.org',
'mobile' => null,
'website' => null,
'timezone' => 'Asia/Singapore',
'coach_id' => 1,
'type_id' => 2, // client
'status' => ClientStatusEnum::ACTIVE,
'gender' => GenderEnum::FEMALE,
I bet, the OCv3 encrypted string is longer than the OCv2 encrypted string. Check the table definition for that email field. If you make it bigger (e.g. TEXT) the issue will go away.
Attention: quick hack.
thanks @alexwenzel , I’d like to avoid this solution, firstly because I have about 12 more encrypted fields
the previous code is used in a seeder and throws the exception.
however, when I use
save() method inside a component, it works fine, but not inside a seeder.
In a Seeder there is usually
Means, when you use fill() and save() the data gets truncated by Eloquent Model somehow