This project is archived and is in readonly mode.

#777 ✓wontfix
Roman Le Négrate

Simpler AR#exists?

Reported by Roman Le Négrate | August 7th, 2008 @ 09:48 PM | in 2.x

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.

Comments and changes to this ticket

  • Frederick Cheung

    Frederick Cheung August 9th, 2008 @ 03:54 PM

    • Tag changed from activerecord, edge, patch, tested, tiny to activerecord, edge, patch, test, tested

    Have your done any benchmarks to quantify the difference?

  • Roman Le Négrate

    Roman Le Négrate August 9th, 2008 @ 04:05 PM

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

  • Pratik

    Pratik August 12th, 2008 @ 03:26 PM

    • 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.

  • Pratik

    Pratik August 12th, 2008 @ 03:26 PM

    • State changed from “invalid” to “wontfix”
  • fearless_fool

    fearless_fool October 26th, 2010 @ 07:19 PM

    • 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.

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Attachments

Pages