I get a strange result upon querying DB records in which the column (VARCHAR) is set to NULL by default the generated query is : SELECT * FROM `contents` WHERE `contents`.`type` IN (''Article'') AND (state <> ''draft''); when contents.state is NULL, then the record IS NOT selected when contents.state is'''' ( empty ) then the record is selected ( obviously when set to any other value too..) is it the ''standard'' behavior ? ( so I''ll have to change the default ..) or should I modify /add anything in the query ? thanks for feedback -- 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 Jun 8, 2012, at 8:04 AM, Erwin wrote:> when contents.state is NULL, then the record IS NOT selected > when contents.state is'''' ( empty ) then the record is selected > ( obviously when set to any other value too..)Yes, it''s how SQL works--NULL is ''unknown'', so comparison with any value returns null. You need a SQL primer, and look especially for three-valued logic. -- Scott Ribe scott_ribe-ZCQMRMivIIdUL8GK/JU1Wg@public.gmane.org http://www.elevated-dev.com/ (303) 722-0567 voice -- 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.
thanks .. I am using now a '''' (empty) default and it works On 8 juin, 16:20, Scott Ribe <scott_r...-ZCQMRMivIIdUL8GK/JU1Wg@public.gmane.org> wrote:> On Jun 8, 2012, at 8:04 AM, Erwin wrote: > > > when contents.state is NULL, then the record IS NOT selected > > when contents.state is'''' ( empty ) then the record is selected > > ( obviously when set to any other value too..) > > Yes, it''s how SQL works--NULL is ''unknown'', so comparison with any value returns null. You need a SQL primer, and look especially for three-valued logic. > > -- > Scott Ribe > scott_r...-ZCQMRMivIIdUL8GK/JU1WhHnuRYL88vP@public.gmane.org://www.elevated-dev.com/ > (303) 722-0567 voice-- 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.