Shouldn''t the length validation of AR use String#jsize to be compatible to UTF-8?
Andreas Schwarz wrote:> Shouldn''t the length validation of AR use String#jsize to be compatible > to UTF-8?I have set up a ticket for this: http://dev.rubyonrails.org/ticket/824
On Sat, 12 Mar 2005 16:27:48 +0100, Andreas Schwarz <usenet-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Andreas Schwarz wrote: > > Shouldn''t the length validation of AR use String#jsize to be compatible > > to UTF-8? > > I have set up a ticket for this: > http://dev.rubyonrails.org/ticket/824I deferred that ticket to milestone 1.x, though I guess a patch which supports this transparently when the gem is installed wouldn''t be too intrusive. Most of the time I''m validating the length of something it''s because: 1) It''s a password or something similar with a minimum length restriction 2) To restrict the max length to that of a database field With the first case the validations would still work, but aren''t the varchar(x) declarations in bytes not characters? Would we need something seperate to validate that?> _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Cheers Koz
Michael Koziarski wrote:> On Sat, 12 Mar 2005 16:27:48 +0100, Andreas Schwarz > <usenet-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: > >>Andreas Schwarz wrote: >> >>>Shouldn''t the length validation of AR use String#jsize to be compatible >>>to UTF-8? >> >>I have set up a ticket for this: >>http://dev.rubyonrails.org/ticket/824 > > > I deferred that ticket to milestone 1.x, though I guess a patch which > supports this transparently when the gem is installed wouldn''t be too > intrusive.Which gem?> Most of the time I''m validating the length of something it''s because: > > 1) It''s a password or something similar with a minimum length restriction > 2) To restrict the max length to that of a database field > > With the first case the validations would still work, but aren''t the > varchar(x) declarations in bytes not characters? Would we need > something seperate to validate that?In MySQL varchar(x) means x characters, if the charset is UTF-8 this can be 30 bytes long.
Reasonably Related Threads
- RJava question(class not found with rJava's vm, though found with alternate vm)
- AR foreign key problem.
- AR - Migrations - how to use a varchar as primary key instead of int ?
- Is there a function that runs AR model with Schwarz Bayesian Information Criteria (BIC)?
- IPv6 support?