Rails fixtures on Linux and Windows

At my current gig I develop on Windows while the rest of the team is working on Linux (but not for long, I just got PartitionMagic and I’m going to dual-boot). This has caused several problems and one of the most vexing is that the Linux dudes can check in fixtures that blow up on my Windows box. Every time it happens I take a look at the offending fixture and it isn’t putting something into a column that has been declared ‘not null.’ So I fix it by adding in some data, but why the hell isn’t it blowing up on their machines (or cruise control, which is on a Linux box)? My colleague Ricky Lui figured it out today. Allow me to quote from his email:


On our Linux machines, MySQL is installed with no default sql_mode. That means
if there's a certain column that's supposedly NOT NULL, your unit tests can
still pass even without setting that column (e.g. through test fixtures).

For MySQL installation on Windows, the default sql_mode is set, so that same
unit test that passes on a linux machine will fail on Windows.

I think it's a good idea to let MySQL catch more errors for you. You can
view and set your sql_mode:

mysql> SELECT @@global.sql_mode;

mysql> SET @@global.sql_mode = traditional;

As per http://dev.mysql.com/doc/refman/5.0/en/server-sql-mode.html, the
'traditional' mode is ' "give an error instead of a warning" when inserting
an incorrect value into a column.'


Nice job Ricky.

Comments

Anonymous said…
Hi Jake - What kind of org do you work in that you are the only Windows dev and everyone else is on Linux? I haven't heard quite that mix before so curious how you got to be the only windows guy.
Jake Scruggs said…
Yeah, it's weird. The client I'm working at right now doesn't have enough computers all the new consultants so I'm working off my laptop.

Popular posts from this blog

What's a Good Flog Score?

SICP Wasn’t Written for You

Point Inside a Polygon in Ruby