Domanda

Sto usando DB ipertable con la parte anteriore di Hyperrecord. C'erano alcuni bug che ci ho riparato. Ma ora le migrazioni mi bloccano. Quando mai migra, mostra l'errore:

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'

Quando guardo il codice o Ruby on Rails Actice_Record. Mostra.

  # 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

Ho provato a rimuovere queste funzioni aggiungendo una correzione nelle inizializzazioni.

module ActiveRecord
  module ConnectionAdapters
    class HypertableAdapter

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

Poi è arrivato con l'errore Nil value occurred while accepting array or hash. Per risolverlo ho aggiunto un nuovo metodo al codice fissa.

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

poi è arrivato con l'errore:

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'

Qualcuno ha un'idea, cosa sta succedendo?

È stato utile?

Soluzione

Questo codice rimuove tutti gli errori. Ma ora le migrazioni funzionano bene, ma non tornano indietro.

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

Quando ho controllato nel file dello schema, mostra il seguente errore:

# Could not dump table "teams" because of following StandardError
#   Unknown type '' for column 'ROW'
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top