DB2 interface for Ruby Milestone
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:
columnprivileges/column_privileges cursor_type field_precision field_scale foreignkeys/foreign_keys free_stmt primarykeys/primary_keys procedurecolumns/procedure_columns procedures setoption/set_option specialcolumns/special_columns statistics tableprivileges/table_privileges
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 }