remult: Data too long for JSON Field

Describe the bug JSON fields are created in the underlying (MySQL) database as TEXT data type which causes “ERROR 1406: Data too long for column ‘json’ at row 1” if the JSON object is too large.

To Reproduce Create an entity with a JSON field type:

@Entity("test",{
    allowApiCrud: true
})
export class Test {
    @Fields.autoIncrement()
    id: number

    @Fields.json()
    json: object
}

Insert a large JSON object to the entity.

Expected behavior JSON fields are created with JSON data type to allow for larger JSON objects to be stored.

About this issue

  • Original URL
  • State: closed
  • Created 5 months ago
  • Comments: 15

Commits related to this issue

Most upvoted comments

Happy to help

If you’re curious, you can see in these tests the difference between mysql & mysql2 returning json :

https://github.com/remult/remult/blob/master/projects/tests/dbs/mysql.spec.ts#L64-L71