Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql到PostgreSql Rails 3 heroku应用程序对/错_Mysql_Ruby_Ruby On Rails 3_Postgresql - Fatal编程技术网

Mysql到PostgreSql Rails 3 heroku应用程序对/错

Mysql到PostgreSql Rails 3 heroku应用程序对/错,mysql,ruby,ruby-on-rails-3,postgresql,Mysql,Ruby,Ruby On Rails 3,Postgresql,一切正常,直到我推到heroku,我才发现这与mysql和postgres显示布尔值的不同方式有关 我在Max OSX上使用Ruby 1.9.2p318和Rails 3.2.2和Mysql 5.2.35 这是我试图运行的查询 @special_offers = Wine.find(:all, :include => [:inventories], :conditions => ["inventories.special = ? AND inventories.warehouse_id

一切正常,直到我推到heroku,我才发现这与mysql和postgres显示布尔值的不同方式有关

我在Max OSX上使用Ruby 1.9.2p318Rails 3.2.2Mysql 5.2.35

这是我试图运行的查询

@special_offers = Wine.find(:all, :include => [:inventories], :conditions => ["inventories.special = ? AND inventories.warehouse_id IN (?)", "true", @wharehouses_array], :order => "inventories.updated_at DESC", :limit => 3)
问题似乎在于
inventory.special=?,“true”
这在mysql上运行良好,但当我推到heroku时就不行了,heroku正在使用postgres

我试着用1和1替换“真”和“t”和“t”和“真”,但似乎什么都不起作用?
更新:
Heroku日志文件



架构文件:用于库存表

create_table "inventories", :force => true do |t|
    t.integer   "wine_id"
    t.integer   "warehouse_id"
    t.integer   "stock"
    t.float     "price"
    t.integer   "quantity_id"
    t.timestamp "created_at"
    t.timestamp "updated_at"
    t.boolean   "available",                        :default => false
    t.boolean   "discount",                         :default => false
    t.string    "markupprofile_id",   :limit => 45
    t.string    "discountprofile_id", :limit => 45
    t.float     "discount_price"
    t.boolean   "special",                          :default => false
  end

使用实际的TrueClass,而不是字符串,Rails将为您将其转换为正确的查询

正确:

"inventories.special = ?", true
不正确:

"inventories.special = ?", "true"

它不会抛出错误,因为第二个仍然会生成有效的查询,它只是在查找记录,其中special是一个包含实际t-r-u-e字符的字符串。

生成的SQL和来自PostgreSQL的错误会有所帮助。一旦你有了这些,有人可以马上告诉你。事实上,一旦你得到了这些,你可能就不需要问了。似乎没有什么有效的错误消息。我查看了heroku日志文件,它没有显示任何错误消息,只是在使用
Wine.find(:all,:include=>[:inventory],:conditions=>[“inventory.special=?”,“true”])时不查询字段
因为postgresql中的“true”值不同?好吧,我将
的“inventory.special=?”,“true”
更改为
的“inventory.special=?”,true
但现在它没有显示任何结果?让我看一看模式文件quickit看起来该列实际上是布尔的,或者在mysql中显示为tinyint,这是否正确?是的,因为您的特殊字段是布尔的,所以请使用true/false。假设您确实有记录,其中special为true,并且您没有看到任何结果,那么这与查询的另一部分有关。
"inventories.special = ?", "true"