Change - Know that nothing stays the same

New path

September 04, 2011

ror

I’m in a new path, I’ve had enough time with laments. Now it’s time for a clean start and make the things right.

I’m starting to look and learn how to make contributions to rails source code. The first steps are not clear, but if you want to play with the bigs players, you need to invest all your efforts to do that.

In this post I’m going to put all my revisions and mind notes. The best way to start is check the guide in Ruby Guides and follow the necessary steps to make a local environment to test and check the code of Ruby On Rails:

http://guides.rubyonrails.org/contributingtorubyonrails.html

When you have the local copy of the code, and run for the first time “rake test” a lot of warnings and errors show up.

In my case, the first error was when I test the ActiveRecord module, the error was:

  1. Failure:

    test_find_multiple_ordered_last(BasicsTest) [/path/to/rails/activerecord/test/cases/base_test.rb:1604]:
    <#<Developer id: 1, name: “David”, salary: 80000, created_at: “2011-09-04 04:39:40”, updated_at: “2011-09-04 04:39:40”>> expected but was
    <#<Developer id: 9, name: “fixture_9”, salary: 100000, created_at: “2011-09-04 04:39:40”, updated_at: “2011-09-04 04:39:40”>>.
    180 tests, 413 assertions, 1 failures, 0 errors, 0 skips

The error it’s in sqlite3 when try to test the ActiveRecord module, the test  testfindmultipleorderedlast return different results and the test didn’t pass.

My next step it’s check this error through MySql. Because of I install the last version of Ruby in my rvm instance, I need to install the mysql gem. The mysql gem 2.8.1 in OSX Leopard have some issues to install, in my case I could install the gem with this command:

gem install mysql – –with-mysql-config=/path/to/mysql_config

It’s important to check where you have installed mysql, not always the path is the same in any installation. This was my error, I have mysql installed in other path, not the common. You only need the option for mysql_config. This error is in mysql too:

rake test_mysql
test_find_multiple_ordered_last(BasicsTest) [/path/to/rails/activerecord/test/cases/base_test.rb:1604]:
<#<Developer id: 1, name: “David”, salary: 80000, created_at: “2011-09-04 18:38:37”, updated_at: “2011-09-04 18:38:37”>> expected but was
<#<Developer id: 11, name: “Jamis”, salary: 9000, created_at: “2011-09-04 18:38:37”, updated_at: “2011-09-04 18:38:37”>>.

I got other errors too, but I need to check if the rest of the errors are for a encoding problem in the database.

OK, isolated the problem, when you have 2 query with more than 1 order parameter if you pass an order instruction to some parameter, rails fails. I imagine it’s a Rails error, not a BD error.

We have 2 instruction to test:

First:

Developer.find :last, :order => ‘developers.name, developers.salary DESC

Second:

Developer.find(:all, :order=> 'developers.name, developers.salary DESC).last

The first instruction generate this sql:

SELECT “developers”.* FROM “developers” ORDER BY developers.name, developers.salary ASC LIMIT 1

The second instruction generate this sql:

SELECT “developers”.* FROM “developers” ORDER BY developers.name, developers.salary DESC

As you can see, the first instruction has an error when parse the “DESC” flag for the second order parameter. Check for others test, I found and tested the rest of the cases (testfindorderedlast, testfindreverseorderedlast and testfindkeepsmultipleordervalues), any of these fails.

Now I need to find where and how manage the parser of the order parameters.


Agustin Vinao
Agustin Vinao.

Paradox: Life is a mystery. Don't waste time trying to figure it out.
Humor: Keep a sense of humor, especially about yourself. It is a strength beyond all measure.
Change: Know that nothing stays the same.