Rails with MySQL makes me scratch my head. Apparently either MySQL (4.1, with InnoDB tables) or Rails thinks that columns with a not null constraint have a default value; e.g. "" for varchar, 0000-00-00 for date. Am I misunderstanding something here? I''ve only touched MySQL in the past two days and was caught by surprise as with PostgreSQL this does not happen. Michael -- Michael Schuerig The Fifth Rider of the Apocalypse mailto:michael-q5aiKMLteq4b1SvskN2V4Q@public.gmane.org is a programmer. http://www.schuerig.de/michael/
Michael Schuerig wrote:>Rails with MySQL makes me scratch my head. Apparently either MySQL (4.1, >with InnoDB tables) or Rails thinks that columns with a not null >constraint have a default value; e.g. "" for varchar, 0000-00-00 for >date. Am I misunderstanding something here? I''ve only touched MySQL in >the past two days and was caught by surprise as with PostgreSQL this >does not happen. > >It is MySQL. You should also be careful about out-of-range data like 1000 into a decimal(3,0) field. MySQL will silently round-down to 999. The motto of MySQL with user data is that the user should be the one to make sure that the data is valid. For example, if you try to insert a non-numeric string into an int field, MySQL will insert 0 and generate a warning, not an error. - Adam
On Saturday 11 June 2005 01:41, Adam Majer wrote:> Michael Schuerig wrote: > >Rails with MySQL makes me scratch my head. Apparently either MySQL > > (4.1, with InnoDB tables) or Rails thinks that columns with a not > > null constraint have a default value; e.g. "" for varchar, > > 0000-00-00 for date. Am I misunderstanding something here? I''ve > > only touched MySQL in the past two days and was caught by surprise > > as with PostgreSQL this does not happen. > > It is MySQL. You should also be careful about out-of-range data like > 1000 into a decimal(3,0) field. MySQL will silently round-down to > 999.Oh dear. Thanks. I''ll stick with PostgreSQL. It''s only because I''m readying some stuff for more general consumption that I''m wrestling with MySQL now. Michael -- Michael Schuerig Those people who smile a lot mailto:michael-q5aiKMLteq4b1SvskN2V4Q@public.gmane.org Watch the eyes http://www.schuerig.de/michael/ --Ani DiFranco, Outta Me, Onto You