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.

Make assert_sql output easier to debug the problem

#2573

This is a small improvement to assert_sql, making the it's output easier to debug the problem.

Fox example for this failing test:


  def test_merged_scoped_find
    poor_jamis = developers(:poor_jamis)
    Developer.with_scope(:find => { :conditions => "salary < 100000" }) do
      Developer.with_scope(:find => { :offset => 1, :order => 'id asc' }) do
        assert_sql /ORDER BY id asc  / do
          assert_equal(poor_jamis, Developer.find(:first, :order => 'id asc'))
        end
      end
    end
  end

Instead of the current output:

Query pattern(s) /ORDER BY id asc  / not found.

You'll get something like this:

Query pattern(s) /ORDER BY id asc  / not found in SELECT * FROM `developers` WHERE (salary < 100000)  ORDER BY id asc LIMIT 1, 1.

Showing the executed queries and making easier to figure put why it isn't the expected result.

Reported by Emilio Tagua · April 27th, 2009 @ 09:31 PM

State: resolved
Milestone: 2.x
Assigned to: nobody
Importance: none

Activity

  1. Repository
    Repository
    • State changed from new to resolved

    (from [4246a79a991af6c4c5a9473d01e805a5ac04624a]) Show executed queries when assert_sql assertion fails [#2573 Make assert_sql output easier to debug the problem state:resolved]

    Signed-off-by: Pratik Naik pratiknaik@gmail.com http://github.com/rails/rails/co...

    April 28th, 2009 @ 10:13 PM