Issue with trait Encryptable in OC v3

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[22001]: String data, right truncated: 1406 Data too long for column 'email' at row 1 

the code

      'name' => 'John Does',
      'email'     => '',
      '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.

1 Like

thanks @alexwenzel , Iā€™d like to avoid this solution, firstly because I have about 12 more encrypted fields :smile:

the previous code is used in a seeder and throws the exception.

however, when I use fill() and save() method inside a component, it works fine, but not inside a seeder.

In a Seeder there is usually Eloquent::unguard() active.
Means, when you use fill() and save() the data gets truncated by Eloquent Model somehow :wink: