Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Simpler AR#exists?

#777

Patch to simplify AR#exists?.

It currently fetches the primary key of the table, but the value is not used after that. The patch makes it only fetch the value '1' (could have been anything else) which simplifies the code and is likely to be slightly nicer on the DB server.

Current tests already cover the change.

Reported by Roman Le Négrate · August 7th, 2008 @ 09:48 PM

State: wontfix
Milestone: 2.x
Assigned to: Pratik Pratik
Importance: none

Activity

  1. Frederick Cheung
    Frederick Cheung
    • Tag changed from activerecord, edge, patch, tested, tiny to activerecord, edge, patch, test, tested

    Have your done any benchmarks to quantify the difference?

    August 9th, 2008 @ 03:54 PM

  2. Roman Le Négrate
    Roman Le Négrate

    @Frederick Cheung No I haven't done any benchmark since performance improvement isn't the primary intent, but rather just a likely bonus.

    August 9th, 2008 @ 04:05 PM

  3. Pratik
    Pratik
    • State changed from new to invalid
    • Assigned user set to Pratik

    Don't really see much benefit in this. But if you could verify that this will work on all the different databases, don't see any harm.

    Thanks.

    August 12th, 2008 @ 03:26 PM

  4. Pratik
    Pratik
    • State changed from invalid to wontfix

    August 12th, 2008 @ 03:26 PM

  5. fearless_fool
    fearless_fool
    • Importance changed from to

    A reason to implement @Roman Le Négrate's change is that it would allow exists?() to work on tables that lack a PK. See also ticket #615 ActiveRecord exists? won't work with keyless tables.

    October 26th, 2010 @ 07:19 PM