我在访问页面时在本地看到此错误:
Mysql2::Error - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'and reference_number > ) ORDER BY reference_number asc LIMIT 1' at line 1:
这是什么意思?该查询不会在生产中失败,但会在本地发生。在digitalOcean上,我看到了:
ssh <username>@107.170.112.8
Welcome to Ubuntu 14.04 LTS (GNU/Linux 3.13.0-24-generic x86_64)
* Documentation: https://help.ubuntu.com/
System information as of Wed Oct 17 22:25:21 EDT 2018
System load: 1.26 Processes: 108
Usage of /: 80.1% of 157.36GB Users logged in: 0
Memory usage: 59% IP address for eth0: 107.170.112.8
Swap usage: 2% IP address for eth1: 10.128.133.134
Graph this data and manage this system at:
https://landscape.canonical.com/
414 packages can be updated.
294 updates are security updates.
Last login: Wed Oct 17 22:25:22 2018 from 65.200.165.210
<username>:~$ mysql --version
mysql Ver 14.14 Distrib 5.5.37, for debian-linux-gnu (x86_64) using readline 6.3
我的msql版本之间不匹配吗?
有问题的查询(Rails 4.15中的activeRecord)是这样的:
other_catalog_item = @current_checkout_location.checked_in_current_catalog_items
.where("catalog_section_id = #{selected_catalog_item.catalog_section_id} and reference_number > #{selected_catalog_item.reference_number}")
.order('reference_number asc')
.limit(1).first
问题是...如果我在本地进行更改,则会冒生产中断的风险。我该怎么办?这个问题的根源是什么?
答案 0 :(得分:1)
查看此
Mysql2::Error - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'and reference_number > ) ORDER BY reference_number asc LIMIT 1' at line 1:
and reference_number > )
是错误的mysql adapters。取决于您本地数据和生产数据是否不同,selected_catalog_item没有参考编号,因此会导致问题
reference_number > #{selected_catalog_item.reference_number}"