Ruby on rails 超表迁移导致rails 2.3.8出现问题
我正在使用HyperRecord前端的Hypertable db。我在里面修复了一些bug。但现在迁移让我陷入困境。每次迁移时,都会显示错误:Ruby on rails 超表迁移导致rails 2.3.8出现问题,ruby-on-rails,ruby-on-rails-plugins,hypertable,Ruby On Rails,Ruby On Rails Plugins,Hypertable,我正在使用HyperRecord前端的Hypertable db。我在里面修复了一些bug。但现在迁移让我陷入困境。每次迁移时,都会显示错误: 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/
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'
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'
我试图通过在初始化中添加修复来删除这些函数
module ActiveRecord
module ConnectionAdapters
class HypertableAdapter
def select_rows(sql, name = nil)
end
end
end
end
然后在接受数组或散列时出现错误Nil值。为了修复它,我在修复代码中添加了新方法
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!
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'
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'
有人知道这是怎么回事吗?这段代码删除了所有错误。但现在迁移运行良好,但不会回滚
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
此修复程序非常适合向上迁移和活动记录模型。唯一剩下的就是迁移回滚。