I am using Hypertable db with the front end of HyperRecord. There were some bugs that i fixed in it. But now migrations get stuck me. When ever i do migrate it shows the error:

rake aborted!
undefined method `select_rows' for #<ActiveRecord::ConnectionAdapters::HypertableAdapter:0xb6f791c4>
.rvm/gems/ruby-1.8.7-p352@r2.3.8/gems/activerecord-2.3.8/lib/active_record/connection_adapters/abstract/database_statements.rb:27:in `select_values'

When i look into the code or ruby on rails actice_record. It shows.

  # Returns an array of arrays containing the field values.
  # Order is the same as that returned by +columns+.
  def select_rows(sql, name = nil)
  end
  undef_method :select_rows

I tried to remove these functions by adding a fix in initializes.

module ActiveRecord
  module ConnectionAdapters
    class HypertableAdapter

      def select_rows(sql, name = nil)
      end
    end
  end
end

Then it came with the error Nil value occurred while accepting array or hash. To fix it i added new method to the fix code.

module ActiveRecord
  module ConnectionAdapters
    class HypertableAdapter

      def select_rows(sql, name = nil)
      end

      def select_values(sql, name = nil)
        result = select_rows(sql, name)
        result.map { |v| v[0] } unless result.nil?
      end
    end
  end
end

then it came with the error:

rake aborted!
You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.map
/.rvm/gems/ruby-1.8.7-p352@r2.3.8/gems/activerecord-2.3.8/lib/active_record/migration.rb:421:in `get_all_versions'

Does any one have an idea, what is going on with it?

有帮助吗?

解决方案

This code removes all the errors. But now migrations runs well, but do not roll back.

module ActiveRecord
  module ConnectionAdapters
    class HypertableAdapter

      def select_rows(sql, name = nil)
        result = execute(sql)
        rows = []
        result.cells.each { |row| rows << row }
        rows
      end

      def select_values(sql, name = nil)
        result = select_rows(sql, name)
        result.map { |v| v[0] } unless result.nil?
      end
    end
  end
end

When i checked into schema file it shows the following error:

# Could not dump table "teams" because of following StandardError
#   Unknown type '' for column 'ROW'
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top