self-referential, polymorphic has_many through helper now a plugin

Thanks to Chris Wanstrath, my polymorphic, self-referential has_many :through module is now a handy plugin.

Read more.

In the process of working with it, I discovered this ActiveRecord oddity:

Dog.find(:all, :conditions => {:name => "Sparky", :likes_treats => 1}) works fine.

But Dog.find(:all, :conditions => {:name => "Sparky", :likes_treats => 1, :favorite_tree => nil}) doesn’t work at all. Apparently ActiveRecord is turning the “ => nil” into “ = NULL” when it needs to be “ IS NULL”, at least for MySQL.

I would look to see if there was a ticket for this already, but the Rails trac is still down. Anybody else run into this?

One response

  1. Yes, I just ran across this too – I ended up changing the data to be -1 instead of NULL.

    I do think it’s a bug though