Archive for October, 2007

IntelliJ IDEA 7 with Ruby (on Rails)

Only today, I noticed that IntelliJ IDEA 7 was released some weeks ago and I saw that it comes with Ruby and Rails support. I decided to check it out and give it a go. For Rails development, I currently use Aptana RadRails as an Eclipse plugin. Even though I like RadRails, it still lacks some features and coherency in my opinion. Also, setting up RadRails as an Eclipse plugin can be a pain in the ass when dealing with the latest beta versions or nightly builds.

So, I downloaded IntelliJ to my Mac, dragged it to my Applications folder and started it. After installing the Ruby plugin (2 clicks and a restart), I was good to go. I played with it for an hour or so and I must say that I'm quite impressed. The interface is clean (better then NetBeans) and stuff is where I look for it. Also code completion is working (in oposite to RadRails) very well. Hopping through code (declarations, views, models, etc) is nice.

I'll be playing with it for the next couple of days and trying out some other stuff and see if it's perhaps worth buying a license.

MySQL 5.0.45 Ubuntu quirks

Recently, Ubuntu 7.10 was released. Since I like new and shiny software, I upgraded some time ago to the beta. Everything looks great, until I ran into some weird behavior while coding. From Rails, I did a standard ActiveRecord find for some objects in my database, but I didn't get any results. Breaking down the query to a minimum didn't give any records back, although I new that there had to be some results.

The following was the case (quite stunned me at first):

mysql> SELECT id,expired_at FROM job_openings
         WHERE CURDATE() <= DATE(expired_at);

Empty set (0.03 sec)

mysql> SELECT id,expired_at FROM job_openings
         WHERE CURDATE() <= DATE(expired_at) AND id=3053;
+------+---------------------+
| id   | expired_at          |
+------+---------------------+
| 3053 | 2007-10-25 14:33:53 |
+------+---------------------+

1 row in set (0.00 sec)

At first I thought that my database (or table) was corrupt, so I got a fresh dump from a production server and loaded it, but the problem persisted. Running the same query on the production server, did gave results. After some more research and talk on #mysql on freenode, I found out that the issue was caused by the fact that the expired_at column (type datetime) has some NULL values and that a bug in MySQL causes to return any results when date() functions are used in the WHEN-clause.

A workaround would be to extend my query with "AND expired_at IS NOT NULL". This worked, but for some reason, adding extra columns to my query, didn't return any results.

At that point I had spent way too much time on the issue and decided to downgrade to 5.0.38 (Ubuntu feisty pacakge), which solved the problem.

Edit: the table was innoDB. I haven't tested this behavior on MyISAM tables.

Webistrano, git and capistrano 2.1.0

Capistrano 2.1.0 has been released last weekend and now officially has GIT support. Since we're moving from SVN to GIT, I tried it and it seems to work pretty wel. At work, we use webistrano to deploy our applications and found out that webistrano didn't want to deploy with GIT.

First, webistrano uses a frozen capistrano version (2.0.0) in the vendor/plugins directory. This I removed. After that, I found out that when deploying, webistrano also calls query_revision() . For SVN, this works, since a remote repository can be queried, but since GIT clones repositories, instead of checking them out as SVN does, the query_revision doesn't quite work.

The quick hack is to replace line 67 in webistrano's lib/webistrano/deployer.rb with:

exchange_real_revision(config) unless config[:scm] == "git"