问题描述
我正在使用 ruby 应用程序通过 activerecord 和 mysql2 gems 查询数据。像 User.find_by(id: 1)
这样的简单查询会返回错误 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 '' at line 1
我开始记录查询,发现查询末尾附加了一个 ASCII 字符 。所以,实际的查询就像
SELECT `tbl_userdetails`.* FROM `tbl_userdetails` WHERE `tbl_userdetails`.`id` = 1 LIMIT 1<0x1b>
数据库.yml
default: &default
adapter: mysql2
pool: <%= ENV["DB_POOL"] || 5 %>
username: <%= ENV['DB_USER'] %>
password: <%= ENV['DB_PASS'] %>
host: <%= ENV["DB_HOST"] %>
database: <%= ENV['DB_NAME'] %>
reconnect: true
strict: false
encoding: 'latin1'
- activerecord 版本 6.0.3.4
- mysql2 版本 0.5.3
- 红宝石版本 2.5.0
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)