Diffrent behaviour for find_or_create_by and find_by #864

Closed
lighthouse-import opened this Issue May 16, 2011 · 0 comments

Comments

Projects
None yet
1 participant

Imported from Lighthouse. Original ticket at: http://rails.lighthouseapp.com/projects/8994/tickets/6464
Created by Robin Wunderlin - 2011-02-24 12:54:19 UTC

There is a different behaviour for "find_or_create_by" and "find_by".

If I use "EventTrack.find_by_profile_id_and_event(5)" it will execute the SQL statement:

SELECT "event_tracks".* FROM "event_tracks" WHERE "event_tracks"."event" IS NULL AND "event_tracks"."profile_id" = 5 LIMIT 1

But if I call the method "EventTrack.find_or_create_by_profile_id_and_event(5)" it will execute the SQL statement:

SELECT "event_tracks".* FROM "event_tracks" WHERE "event_tracks"."profile_id" = 5 LIMIT 1

I would expect that the WHERE cause of both SQL statements would be

WHERE "event_tracks"."event" IS NULL AND "event_tracks"."profile_id" = 5 LIMIT 1

@tomstuart tomstuart pushed a commit to econsultancy/rails that referenced this issue May 17, 2011

@Fryguy @gbuesing Fryguy + gbuesing String #to_time and #to_datetime: handle fractional seconds [#864 sta…
…te:resolved]
1d93464
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment