Hello all, I have a strange one here but there''s probably a very simple solution (though I''ve been unable to google it). I have a varchar(100) column called name (t.string :name, :limit => 100, :null => false). I have a .... validates_uniqueness_of :name, :scope => :event_group_id, :case_sensitve => false which is producing the following SQL ... SELECT `event_categories`.id FROM `event_categories` WHERE (`event_categories`.`name` = BINARY ''road'' AND `event_categories`.event_group_id = 790727023) LIMIT 1; Note the BINARY in the query. How could this happen? I have other requests to that table (JQuery autocomplete, for example) and it doesn''t introduce the BINARY. I am running MySQL version 5.1.49-1ubuntu8.1 Rails 2.3.8 Any pointers would be great TIA -ants -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Jan 21, 2011, at 2:56 PM, Ants Pants wrote:> Hello all, > > I have a strange one here but there''s probably a very simple > solution (though I''ve been unable to google it). > > I have a varchar(100) column called name (t.string :name, :limit => > 100, :null => false). > > I have a .... > validates_uniqueness_of :name, > :scope => :event_group_id, > :case_sensitve => false > > which is producing the following SQL ... > SELECT `event_categories`.id FROM `event_categories` WHERE > (`event_categories`.`name` = BINARY ''road'' AND > `event_categories`.event_group_id = 790727023) LIMIT 1; > > Note the BINARY in the query. How could this happen? > > I have other requests to that table (JQuery autocomplete, for > example) and it doesn''t introduce the BINARY. > > I am running MySQL version 5.1.49-1ubuntu8.1 > Rails 2.3.8 > > Any pointers would be great > > TIA > > -ants >Since, by default, MySQL is case-insensitive, that is the way that a case-SENSITIVE comparison is made. Does it make a difference if you take the ":case_sensitive => false" off of the validation? -Rob Rob Biedenharn Rob-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org http://AgileConsultingLLC.com/ rab-/VpnD74mH8+00s0LW7PaslaTQe2KTcn/@public.gmane.org http://GaslightSoftware.com/ -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 21 January 2011 21:41, Rob Biedenharn <Rob-GBZH0y1GwQfnZcttdmLDtcI/UQi/AW5J@public.gmane.org> wrote:> On Jan 21, 2011, at 2:56 PM, Ants Pants wrote: > > Hello all, > > I have a strange one here but there''s probably a very simple solution > (though I''ve been unable to google it). > > I have a varchar(100) column called name (t.string :name, :limit => 100, > :null => false). > > I have a .... > validates_uniqueness_of :name, > :scope => :event_group_id, > :case_sensitve => false > > which is producing the following SQL ... > SELECT `event_categories`.id FROM `event_categories` WHERE > (`event_categories`.`name` = BINARY ''road'' AND > `event_categories`.event_group_id = 790727023) LIMIT 1; > > Note the BINARY in the query. How could this happen? > > I have other requests to that table (JQuery autocomplete, for example) and > it doesn''t introduce the BINARY. > > I am running MySQL version 5.1.49-1ubuntu8.1 > Rails 2.3.8 > > Any pointers would be great > > TIA > > -ants > > > Since, by default, MySQL is case-insensitive, that is the way that a > case-SENSITIVE comparison is made. Does it make a difference if you take > the ":case_sensitive => false" off of the validation? > > -Rob > > Rob Biedenharn > Rob-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org http://AgileConsultingLLC.com/ > rab-/VpnD74mH8+00s0LW7PaslaTQe2KTcn/@public.gmane.org <Rob-/VpnD74mH8+00s0LW7PaslaTQe2KTcn/@public.gmane.org> > http://GaslightSoftware.com/ > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. >No. In fact, I only added the case_sensitive flag to see if made a difference. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.