Can someone tell me I’m not going mad.
We have a very large rails app, with lots of things like:
has_many :links, :foreign_key => :product_id
has_many :links, :foreign_key => :content_id
If we run this test on Rails 3.0 we get:
links WHERE (
links.product_id = NULL)
If we run this test on Rails 3.2 we get:
product_id IS NULL
Notice the VERY BIG change in how Rails check for NULL (it may not look
like a big change, but it is).
In the first case (3.0) we get NO records, as you would expect on a new
record, and as everything in our code assumes.
In the second case (3.2) we get ALL RECORDS that have an empty
This is obviously quite a change.
We use our ‘links’ table to store many kinds of relationships between
objects in our system.
So for a link between a ‘Member’ and a ‘Boat’, the product_id field
be blank and just the member_id and boat_id would be filled in.
Under rails 3.0 this all works fine.
Under rails 3.2, EVERY SINGLE use of has_many / has_many :through now
returns ALL unrelated records for every query on a new record, simply
because of the change in NULL checking.
ps. caps used for highlighting, not shouting.
Does anyone know if this is expected behaviour?