This project is archived and is in readonly mode.

#2573 ✓resolved
Emilio Tagua

Make assert_sql output easier to debug the problem

Reported by Emilio Tagua | April 27th, 2009 @ 09:31 PM | in 2.x

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'))

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.

Comments and changes to this ticket

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=""></a>

People watching this ticket

Referenced by