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.

Improve test coverage and add :having option to finder, hm and habtm.

#1028

This patch is divided in 3 parts:

  1. Improve test coverage when using option :group in find. There were no tests in finder using this option.
  2. Add the option :having to finder, to be used in combination with the :group option. So it can be used in a SELECT statement to filter the records that a GROUP BY returns.
  3. Include :having in has_many and has_and_belongs_to_many scope since both can use the option :group and therefore having can be very helpful in some situations when filtering records.

Added tests and docs that covers all new features.

Reported by Emilio Tagua · September 11th, 2008 @ 09:10 PM

State: committed
Milestone: 2.x
Assigned to: Michael Koziarski Michael Koziarski
Importance: none

Activity

  1. Emilio Tagua
    Emilio Tagua

    Test coverage in a single patch file so it can be applied separately from the one adding :having option.

    September 11th, 2008 @ 09:44 PM

  2. Emilio Tagua
    Emilio Tagua
    • Assigned user set to Michael Koziarski

    Modified tests and relationships so the test can also work on postgres.

    Tested mysql, postgres and sqlite3.

    September 11th, 2008 @ 11:17 PM

  3. Emilio Tagua
    Emilio Tagua

    Since the test coverage improvement was commited i created a single patch for adding the :having option to find, hm and habtm associations.

    Also tested on mysql, postgres and sqlite3.

    September 12th, 2008 @ 02:26 PM

  4. Emilio Tagua
    Emilio Tagua

    Michael,

    After applying the patch with test coverage improvement, you told me to hold adding the option having to finders until Rails 2.2 was out.

    That time as come, so i rebased the diff to master.

    Tested on mysql, postgres and sqlite3.

    November 21st, 2008 @ 10:23 PM

  5. Repository
    Repository
    • State changed from new to committed

    (from [97403ad5fdfcdfb2110c6f8fd0ebf43b7afc4859]) Add :having option to find, to use in combination with grouped finds. Also added to has_many and has_and_belongs_to_many associations.

    Signed-off-by: Michael Koziarski michael@koziarski.com [#1028 Improve test coverage and add :having option to finder, hm and habtm. state:committed] http://github.com/rails/rails/co...

    December 1st, 2008 @ 07:23 PM