pat/gutentag

Tag name too long

Closed this issue · 2 comments

Hey there,

using this lib in a Rails 5.2.0 project right now and in fact I'm quite happy with it. However, there's one thing I stumbled over (or rather the client I'm working for stumbled over):

The default migration sets up the gutentag_tags-table with name defined as string, which will translate to VARCHAR(255) on MySQL.

However, there is no validation in place that checks that the tag for being not longer than 255 chars.

I wonder what the best way to fix this is (happy to provide a PR once we've discussed the solutions :))

  1. Just have the validation made on app side in the model?
  2. Add the validation to the existing ones?
  3. Make the name column a text column? (I know, having tags longer than 255 chars sounds wild :))

Anything you'd prefer? For now I'll go with option 1 in our app.

pat commented

Heya Robin 👋

I think option 2 would be ideal - and really, we'd want the validation length tied to Rails' default string length, rather than hard-coding it directly in this gem. Wonder how hard it is to find and use that value?

FYI seems like that MySQL enforces a limit on string, while others don't. See: https://github.com/rails/rails/blob/74c4017daff90df6bebf260cbcec03c73aa3be10/activerecord/test/cases/migration/column_attributes_test.rb#L40-L46

I have a flexible solution in works, just have to get the tests to pass :)