Running activerecord

I wanted to test my prototype ADO.NET database wrappers for SQLite and
MySQL, so I thought I would see how far I could get in an attempt to run
activerecord. Running activerecord is of course a necessary step in the
path to running Rails. At this point I’m simply trying to get “require
‘active_record.rb’” to work, which in turn requires activesupport. Here
are some issues I’ve come across thus far:

(1) Missing method File.expand_path

  • Adapted the implementation from Ruby.NET, along with some other
    unimplemented methods from File. I will check on licensing issues
    before posting a patch.

(2) rubygems is not yet running in IronRuby

  • Commented out all “require ‘rubygems’” in the activerecord and
    activesupport source, since they are not absolutely necessary (i.e.
    rubygems is used to grab packages not present on the local
    filesystem).

(3) Missing method Class.method_added

  • This is just a ‘dummy’ method that gets overridden - see patch for
    ModuleOps.cs

(4)
C:\brian\ironruby\trunk\src\IronRuby.Libraries\Builtins\Kernel.cs:611:in
`InstanceEval’: instance_eval on Module or Class needs singleton support
(NotImplementedError)

  • It seems that instance_eval has different semantics when invoked
    with a class or method as receiver. I haven’t yet worked out what is
    involved with implementing this method, so for the time being I
    commented out the NotImplementedError in Kernel.cs:
    //if (self is RubyModule) {
    // throw
    RubyExceptions.CreateNotImplementedError(“instance_eval on
    Module or Class needs singleton support”);
    //}

(5) :0:in __init__': wrong number or type of arguments fordefine_method’ (ArgumentError)

  • Problem: current implementation of define_method does not accept
    Proc objects as arguments, hence the following line in
    activesupport-2.0.2\lib\active_support\core_ext\module\attr_accessor_with_default.rb
    throws an exception:

     define_method(sym, block_given? ? block : Proc.new { default })
    
  • Solution: added an overload for DefineMethod that accepts a Proc
    object as an argument; see patch for ModuleOps.cs

(6) Missing method Thread.critical

  • Hacked a prototype implementation - see patch for ThreadOps.cs (it’s
    ugly and purely for the purposes of trying to get activerecord
    to import :slight_smile:

(7) Missing method Dir.glob

  • Adapted the implementation from Ruby.NET (see (1) above)

(8) Missing method File.basename

  • Adapted the implementation from Ruby.NET (see (1) above)

(9) Problem with
activesupport-2.0.2\lib\active_support\core_ext\array\conversions.rb

  • unknown: Cannot cast from ‘Microsoft.Scripting.SymbolId’ to
    ‘Ruby.Builtins.Proc’
    (ArgumentError)

  • This is the offending piece of code in conversions.rb:

    def to_param
      map(&:to_param).join '/'
    end
    

    I must say that I’m not familiar with the &:symbol syntax. Anyone
    have any suggestions here?

  • For the time being I have commented out this method in
    conversions.rb.

(10) Libraries ‘enumerator.so’ and ‘bigdecimal.so’ not available

  • Solution: commented out the requires in the activesupport source for
    the time being

(11) Problem with the Ruby library ‘rational.rb’:
:0:in `main’: Can’t inherit from a class without a default or code
context constructor (System::NotSupportedException)

  • The problem is that Rational is a subclass of Numeric, which is an
    abstract class with no constructor:
    class Rational < Numeric
  • Solution: hacked Ruby.Builtins.Numeric so that it is no longer
    abstract, and has a zero-arg constructor - see patch for Numeric.cs

(12)
C:\brian\ironruby\trunk\src\IronRuby.Libraries\Builtins\Kernel.cs:804:in
`Require’: Expression transformation not implemented:
MemberAssignmentExpression (System::NotImplementedException)

  • The problem is in the Ruby library date/format.rb, although I
    haven’t narrowed it down further than that.
  • Solution: commented out all “require ‘date’” for the time being

(13) Problem with the Ruby library delegate.rb: Class.new not supported
(e.g. no zero-arg constructor for “Class”)

This is as far as I have got at this point - hopefully someone might
find all this useful.

  • Brian

Brian Blackwell:

I wanted to test my prototype ADO.NET database wrappers for SQLite and
MySQL, so I thought I would see how far I could get in an attempt to
run activerecord. Running activerecord is of course a necessary step in
the path to running Rails. At this point I’m simply trying to get
“require ‘active_record.rb’” to work, which in turn requires
activesupport. Here are some issues I’ve come across thus far:

… awesome list of observations elided …

Thanks for doing this work, Brian! This will give me a bunch of things
to look at around the core libs this weekend.

-John

Hey Brian - can you share your prototype ADO.NET wrappers for SQLite?
We’re at the point where we need a DB to boot Rails.

Thanks,
-John

I submitted an implementation of File.expand_path a while ago but it
hasn’t
been comitted yet. If your implementation works better go for it. I need
it
for some things I’m doing with IronRuby too.

-Jayme

On Fri, Apr 18, 2008 at 5:56 PM, John L. (IRONRUBY)
[email protected]

Hi John,

No worries - see the attached zip file which contains the Ruby SQLite3
driver with a couple of minor modifications (in particular the modified
database.rb loads the ADO.NET wrapper instead of the native driver). The
ADO.NET wrapper itself can be found in the directory
‘sqlite3\driver\ironruby’. Although it is still very much a prototype, I
have been able to get a simple activerecord use case up and running
(with a few workarounds for remaining IronRuby bugs) which creates
tables and performs queries. The required SQLite3 ADO.NET DLL can be
found at http://sqlite.phxsoftware.com.

Cheers,
Brian

On Wed, 21 May 2008 15:30:38 -0700, “John L. (IRONRUBY)”
[email protected] said:

Brian Blackwell:

No worries - see the attached zip file which contains the Ruby SQLite3
driver with a couple of minor modifications (in particular the
modified database.rb loads the ADO.NET wrapper instead of the native driver).
The ADO.NET wrapper itself can be found in the directory
‘sqlite3\driver\ironruby’. Although it is still very much a prototype,
I have been able to get a simple activerecord use case up and running
(with a few workarounds for remaining IronRuby bugs) which creates
tables and performs queries. The required SQLite3 ADO.NET DLL can be
found at http://sqlite.phxsoftware.com.

Cool. Thanks!
-John

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs