I’ve completed my first pass at
porting the PHP ibm_db2 extension to Ruby. If anyone out
there has both Ruby and DB2 installed on a Unix machine, I would
appreciate hearing if you can reproduce my results.
If you pick up the
latest
code and run it, you should now see
118 tests, 124 assertions, 0 failures, 0 errors
As the PHP extension I am porting was accompanied by
118 tests,
this is significant.
The first thing to note is that I ran out of test cases before I
ran out of code. Functions which were not ported due to a
lack of test cases:
So, at this point, all that can be said is that the code does
what the test test for. It might actually do quite a bit more
than that as much of the logic is largely untouched. Areas
where I likely injected bugs would be in language specific areas,
like binding obscure data types as
DB2::PARAM_INOUT.
Speaking of DB2::PARAM_INOUT, I had to work around
one problem with Ruby 1.8, as I could not successfully resolve
rb_dvar_asn at runtime.
void var_assign(char *name, VALUE value) {
#if TODO
// this compiles and links, but fails to resolve at runtime
rb_dvar_asgn(rb_intern(name_id), value);
#else
// so we do it the hard way
ID inspect;
char *expr, *statement;
long expr_len;
inspect = rb_intern("inspect");
value = rb_funcall(value, inspect, 0);
expr = rb_str2cstr(value, &expr_len);
statement = ALLOC_N(char, strlen(name)+1+expr_len+1);
strcpy(statement, name);
strcat(statement, "=");
strcat(statement, expr);
rb_eval_string(statement);
free(statement);
#endif
}
Sam & James,
Talk about synchronicity — we were talking in the lunchroom about a potential partner who might want to use our (Rails-based) application and is currently using a DB2-based product. We support Postgres and Oracle and know we’ll need to support SQLServer, but have no experience at all with DB2. I thought I’d take a look around to see what kind of Ruby support for DB2 there is (at all), but before that I did my weblog rounds (including intertwingly.net which I hadn’t visited in a few days) and found you talking about this very thing. Spooky.
Glad to see you’re the guys working on the driver.
That would indicate that your tests directory (/tmp/rubydb2/tests) is most likely empty. Which would make sense because php2ruby.rb has the same problem.
Currently we are evaluating Ruby on Rails with DB2. Its not a very complex application - just CRUD operations and 100+ users. We want to make sure Ruby’s DB2 driver is capable of doing that. I didn’t find enough test cases/results to support this. It would be great if you could post some more results, list of CLI operations supported and NOT supported,etc. A Windows version would be great! to make such decisions quickly.