Why do rails translate a TEXT column up to 65535 characters?

I am saving a raw letter in a TEXT column in MySQL with Ruby on Rails. It continues to truncate to 65535 characters, does anyone know what causes this?

MySQL works with max_allowed_packet=64M

Using InnoDB for a storage engine.

+3
source share
4 answers

It is truncated to this length because ... well, that will fit the TEXT column .

You need MEDIUMTEXT or LONGTEXT if you want to save more.

+13
source

Ruby on Rails did not truncate, MySQL did.

TEXT type is limited by characters 2^16 - 1 = 65535, see documentation .

+2
source

65535 " " - 2 ^ 16 - 1. , TEXT MySQL.

+1

I'm not a Ruby specialist, but the number 65535 caught my attention - it's 16 bits (minus 1, which is usually special). You have probably come across a wall of size limits for the type you are using.

+1
source

All Articles