Same error explained here: https://stackoverflow.com/a/48477882/1457270
Nov 26, 2020
8
Level 5
SQLSTATE[22001] : String data too long
Good afternoon all,
I get the following error :
SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'googmaps'
I added a column to my database table where the user can insert a 'Google maps'-link. As you probably can imagine, these links tend to be long :-/
This is my migration scheme for this field:
$table->string('googmaps')->nullable();
This is my validation in controller :
'googmaps' => ['nullable', 'active_url'],
I did not put a max of characters as a condition, but assume this error is thrown as a string has a max. length of 255 characters. (not sure if this is 100%, just how I concluded)
Is this just a matter of changing the type in my migration scheme to f.ex. text or longtext?
Or is this not really correct?
Thank you for your advice!
Level 122
URLs should never be more than 2048 characters.
$table->string('googmaps',2048)->nullable();
The default is just 255
1 like
Please or to participate in this conversation.