我有一个SQLite和MariaDB的查询问题。在开发中,我使用sqlite,但在服务器中我们使用MariaDB。在开发以下查询作品Rails的activerecord查询工作在sqlite不在MySql
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查询。 –