1

我在 HyperRecord 的前端使用 Hypertable db。我修复了一些错误。但是现在迁移让我陷入困境。当我进行迁移时,它会显示错误:

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'

当我查看 rails actice_record 上的代码或 ruby​​ 时。表明。

  # 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

我试图通过在初始化中添加修复来删除这些功能。

module ActiveRecord
  module ConnectionAdapters
    class HypertableAdapter

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

然后它带有错误Nil value occurred while accepting array or hash。为了修复它,我在修复代码中添加了新方法。

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

然后它出现了错误:

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'

有没有人有一个想法,这是怎么回事?

4

1 回答 1

0

此代码删除所有错误。但现在迁移运行良好,但不回滚。

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

当我签入架构文件时,它显示以下错误:

# Could not dump table "teams" because of following StandardError
#   Unknown type '' for column 'ROW'
于 2011-09-09T11:23:51.267 回答