Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Postgresql doesn't accepts limits on text columns #8276
The long story: PostgreSQL doesn't take a limit for "text" columns so developers must choose between removing :limit from their binary column definitions, and not being able to target pgsql.
This change drops :limit specifications, when migrations are applied against a pgsql database. It's not ideal, because the limit information is lost. However, the mysql adapters do something similar, so I hope the approach is OK.
A better long-term solution might be to map :text columns without :limit to "text", and :text columns with :limit to "character varying(xxx)". However, that requires changes in the code that maps postgresql types back into Rails types, and this change seems like a smaller step in the same direction.
Testing: I added a table to postgresql_specific_schema that uses :limit on :text and :binary columns. Setting up this table fails without the patch in this pull request. I also added a couple of unit tests to a new sql_types_test file, which follows the convention in the MySQL adapter tests.
Please let me know if this patch needs more work, and thank you very much for Rails!
@carlosantoniodasilva Sorry for being confusing! Should I add a comment saying what the table is for?
@rafaelfranca I was hoping to backport this to 3-2-stable, like I did for #6328 / #6418. Should I add the entry to the CHANGELOG there? I'm sorry if I'm doing this wrong by the way, I thought bug fixes should first be applied to master and then backported, but I'm not sure how well that works for the CHANGELOG.
Thank you for your guidance!