我在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'
有没有人有想法,发生了什么事?
答案 0 :(得分: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'