Several months ago I decided to take a look at Ruby, in particular Rails, to see what all the fuss was about. Since Rails requires a database (of course) I thought I would see what could be done in getting it set up with Ingres. Since there is already someone working with a client of Ingres to produce a “native” Ingres driver for ruby I had a look at the ODBC offerings.
The default binding for ODBC appears to be available from http://www.ch-werner.de/rubyodbc/. Building the binding on Windows (this week I happen to be running windows) went ok. The subsequent tests did not go so well :(.
The following test fails:
$p = $c.proc("insert into test (id, str) values (?, ?)") {}
$p.call(3, "FOO")
$p[4, "BAR"]
An ODBC trace shows that integers as being passed to Ingres as SQL_VARCHAR. This sort of thing is allowed, if a little disagreable, with MySQL but Ingres does not like it.
If you apply the following patch to odbc.c the tests will complete:
diff -rup ruby-odbc-0.998/odbc.c ruby-odbc-0.998_patched/odbc.c
--- ruby-odbc-0.998/odbc.c 2006-05-21 09:38:30.000000000 +0200
+++ ruby-odbc-0.998_patched/odbc.c 2006-05-26 19:44:47.450091400 +0200
@@ -6151,6 +6151,7 @@ stmt_exec_int(int argc, VALUE *argv, VAL
if (coldef == 0) {
switch (ctype) {
case SQL_C_LONG:
+ stype = SQL_INTEGER;
coldef = 10;
break;
case SQL_C_DOUBLE:
Looking at the rest of the code more changes are needed since the ODBC binding sets the default type to SQL_VARCHAR without correcting for other types. If I get more time next week I will review the rest of the code in this function and post the complete diff.
Add New Comment
Viewing 3 Comments
Thanks. Your comment is awaiting approval by a moderator.
Do you already have an account? Log in and claim this comment.
Do you already have an account? Log in and claim this comment.
We are also completing a proper RoR Adaptor for ODBC/JDBC that will work with ODBC and JDBC accessible databases.
You can pop me a mail if you are interested in a pre-release.
Do you already have an account? Log in and claim this comment.
I may take you up on that offer
grant
Do you already have an account? Log in and claim this comment.
Also, if you are interested in testing a Pre-Release version of our RoR Data Adapter for Ingres then please let me know and I shall arrange to have this made available to you ...