datamapper / do

DataObjects
147 stars 73 forks source link

Add support for the upcoming JRuby 1.7 #30

Closed bbrowning closed 12 years ago

bbrowning commented 12 years ago

Two things have changed that impact DataObjects since JRuby 1.6:

1) Java exceptions no longer inherit from Ruby's StandardError.

Because of this, the rescue clauses for loading the JDBC drivers all now handle a java.lang.ClassNotFoundException in addition to StandardError.

2) org.jruby.RubyBigDecimal was moved to org.jruby.ext.bigdecimal.RubyBigDecimal.

To keep from doing any runtime Java Reflection, AbstractDriverDefinition and Sqlite3DriverDefinition were modified to never reference RubyBigDecimal directly and instead take advantage of JRuby numeric coercion to get java.math.BigDecimal values from RubyBigDecimals and instantiate RubyBigDecimals via String values inside the Ruby runtime instead of direct instantiation.

All specs were run and pass for do_derby, do_h2, do_hsqldb, and do_sqlite3 which gives me confidence in the BigDecimal change.

For all other drivers, connection_spec was run to verify it at least gets past the java.lang.ClassNotFoundException which was being thrown as soon as the driver was required under JRuby 1.7.

pietia commented 12 years ago

nice job!

bbrowning commented 12 years ago

Code changed to only rescue java.lang.ClassNotFoundException when loading JDBC drivers. Tested to work on both JRuby 1.6.7 and 1.7.