我有一個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查詢。 –