Archive for November, 2006

Rails and SQL Server Update

November 28th, 2006 by papillon

After a couple of weeks working with Ruby on Rails and SQL Server 2005, certain aspects slowly crystalize:

1. The ADO DB driver (which uses win32ole) does not work on Ruby 1.8.4 and 1.8.5. I can not help but wonder who besides me actually uses Rails and SQL Server 2005 ? It justs segfaults on the very first access. So: Do not use it.

2. The ODBC driver of ActiveRecord 1.14.4 does not like the way the SQLServer Adapter creates the requests of the paginator class (SELECT TOP 20 (SELECT …)). It just stops with an “argument out of range” error.

3. What actually does work is this combination: Ruby 1.8.5 + Rails (Release Candidate 1 of Rails 1.2), using the ODBC driver. The ODBC connection seems to be preferred over the ADO one, and with the latest changes to the SQL Server Adaptor in ActiveRecord, the argument out of range error is gone as well.

4. Decimal columns seem to work fine now. Prior to the update, I had the problem that “1,5″ always got casted into “1.0″, maybe because the separator is a comma and not a dot in my case.

5. What still does not work: DateTime columns with dates prior to the year that the Ruby Time class accepts, so this change is necessary:

In \ruby\lib\ruby\gems\1.8\gems\activerecord-\
lib\active_record\connection_adapters\sqlserver_adapter.rb around line 105 (cast_to_datetime) and line 116 (string_to_time):


return Time.mktime(value.year, value.mon,, value.hour, value.min, value.sec)


return, value.mon,, value.hour, value.min, value.sec)

If the column is a DateTime, ActiveRecord should return a DateTime, IMHO.

Dates like 1754-01-01 14:00:00.000 work with this change. Note: 1753 is the earliest date accepted by SQL Server, and ActiveRecord really should accept it.

6. Since I have to work with a legacy database which uses ISO-8859-1 as encoding, the whole rails application has to use the same. Rails 1.2 seems to default to UTF-8, which e.g. breaks the truncate function when it encounters an Umlaut.

Fix: in environment.rb, add the following lines
# Include your application configuration below

# Set multibyte encoding to none.

Bottom line: Update to Rails 1.2 and use the ODBC connection for SQL Server 2005.

Development update

November 18th, 2006 by papillon

NWNX4 is making good progress !

As of today, there are two types of database plugins (SQLite and MySQL), and a nifty Timer plugin for accurate performance measures. There are lots of huge and small improvements everywhere. I am really exited about how nicely NWNX4 develops.

I’ve been through 4 prototypes now, each one adding a bit more functionality, with the last one quite a lot (MySQL support for example).

Linking against the mysql client library (which can be installed optionally with the server) became quite an adventure today. MySQL AB seems to use Visual C++ 2003, while I use the 2005 version. This leads to all kinds of nasty problems, effectively, you can not use their binary static library. I had to recompile it on 2005 to make it work. The upside is: MySQL versions 4.1 and 5.0 are equally supported by a single plugin !

These libs are needed for NWNX4:


You can just open the .sln file in the windows source package, let VS 2005 convert it, and then compile the mysqclient project. Be sure to use the correct configuration! “classic nt” worked for me, while the default “authent” results in a library that complains about the server beeing not the (commercial) enterprise one. Oh well.

Development update

November 3rd, 2006 by papillon

I haven’t received my copy of NWN2 yet, so right now it is difficult to set a release date for the prototype (i.e. alpha) version. I think it is going to be in the next few days. It will not be a fully developed version with all the bells and whistles – but a functional prototype without a shiny GUI in the first few weeks.

The first database plugin (SQLite) is done and seems to work fine, although I did not get a chance to fully test it. Right after the first release, the plan is to continue work on the plugin interface, and after that is done, move on to the other plugins like SQL2005, MySQL, and so on. I plan to outsource some of those plugins, since I will not be able to do them all on my own.