【发布时间】:2018-01-09 11:06:45
【问题描述】:
我有一个关于 sqlite 和 MariaDB 的查询问题。在开发中我使用 sqlite,但在服务器中我们使用 MariaDB。正在开发以下查询工作
Author.includes(:books, employes: :universities).where("universities.id is ? and books.year is ?",
@author.employes.first.universities.first.id, @book.jahr).references(:employes, :books)
但在生产中这会产生错误。当我更改为 = 时,它在服务器上工作,但在本地不会产生任何结果。
Author.includes(:books, employes: :universities).where("universities.id = ? and books.year = ?",
@author.employes.first.universities.first.id, @book.jahr).references(:employes, :books)
这在服务器上有效,但在本地没有结果。
编辑 如果我有这样的东西怎么办?
Author.includes(:books, employes: :universities).where("universities.id = ? and books.year = ? and employes.name like ? and id IN ?",
@author.employes.first.universities.first.id, @book.jahr, "%#{@employe.name}%", [1,2,3]).references(:employes, :books)
【问题讨论】:
-
第一:在开发和生产中使用不同的数据库服务器的基本架构设计失败......第二检查生成的SQL查询。
标签: mysql ruby-on-rails sqlite activerecord mariadb