You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This means that longer posts (longer than ~8000/9000 words in a language like English) can't be stored without having the database to throw an error.
(Note that you don't have this limitation on SQLite, where the maximum size of a data type isn't enforced and it only obeys the laws of SQLITE_MAX_LENGTH, which is usually ~1GB).
Steps to reproduce (if necessary)
Steps to reproduce the behavior:
Create a post with more than 64K characters on a MySQL backend
Submit
Submission will fail - a database error will be logged
Expected behavior
Posts up to a reasonable length for a blog article should be allowed on all the supported databases.
If you have an existing database, change the data type of posts.content:
ALTERTABLE posts MODIFY COLUMN content MEDIUMTEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL;
Proposal
Change posts.content data type from TEXT (size: 2^16 on MySQL) to MEDIUMTEXT (size: 2^24 on MySQL).
It's quite straightforward how to do it from schema.sql or via alter commands, but I'm not familiar enough with the SQL generation logic in db/create.go (I could take a look into it if there's interest in a PR though). At a first glance it seems that a new ColumnTypeMediumText needs to be added and then handled (as MEDIUMTEXT for MySQL, and simple TEXT for SQLite), but I'm not sure if this will cover everything (plus I guess that there would also be a migration logic to add).
The text was updated successfully, but these errors were encountered:
Describe the bug
posts.content
is modelled as atext
column onschema.sql
.The
TEXT
data type has a limit of 2^16=64KB on MySQL.This means that longer posts (longer than ~8000/9000 words in a language like English) can't be stored without having the database to throw an error.
(Note that you don't have this limitation on SQLite, where the maximum size of a data type isn't enforced and it only obeys the laws of
SQLITE_MAX_LENGTH
, which is usually ~1GB).Steps to reproduce (if necessary)
Steps to reproduce the behavior:
Expected behavior
Posts up to a reasonable length for a blog article should be allowed on all the supported databases.
Application configuration
Version or last commit:
N/A
Workarounds
content
column on theposts
table - fromtext
tomediumtext
.posts.content
:Proposal
Change
posts.content
data type fromTEXT
(size: 2^16 on MySQL) toMEDIUMTEXT
(size: 2^24 on MySQL).It's quite straightforward how to do it from
schema.sql
or viaalter
commands, but I'm not familiar enough with the SQL generation logic indb/create.go
(I could take a look into it if there's interest in a PR though). At a first glance it seems that a newColumnTypeMediumText
needs to be added and then handled (asMEDIUMTEXT
for MySQL, and simpleTEXT
for SQLite), but I'm not sure if this will cover everything (plus I guess that there would also be a migration logic to add).The text was updated successfully, but these errors were encountered: