Has_one & foreign_key - generating bad SQL

  • MODEL -

class Document < ActiveRecord::Base

has_one		:user,
		:class_name => "User",
		:foreign_key => "fkey",
		:conditions => "user = 'NAME'"

end

  • GENERATED SQL (per the .log) -

SELECT FIRST 1 * FROM table_name WHERE (table_name.fkey IS NULL AND
(user_id = ‘NAME’))

What I can’t figure out is what the “IS NULL” is doing inside the SQL.

Any ideas?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs