mysql2 驱动程序似乎编写了无效查询
我正在其他人开发的 Rails 应用程序之上开发一个应用程序层。
他的应用程序使用了一个名为 request_logger 的模块来写入表,在 ruby1.8/rails2/mysql gem 下工作正常,但在我的 ruby1.9/rails3/mysql2 环境中,activerecord 崩溃了,提示生成的查询无效。
显然,所有 mysql 关系名称都用双引号而不是反引号括起来。
对 activerecord 本身的调用只是设置了一堆属性
log.attributes = {
:user_id => user_id,
:controller => controller,
...etc
}
,然后调用
log.save
所以我倾向于它不是狡猾的调用。有什么建议吗?
I'm developing an application layer on top of a rails app developed by someone else.
His application uses a module called request_logger to write to a table, which worked fine under ruby1.8/rails2/mysql gem, but in my ruby1.9/rails3/mysql2 environment, activerecord falls over, suggesting that the generated query is invalid.
It obviously is, all mysql relation names are wrapped in double quotes instead of backticks.
The call to activerecord itself just sets a bunch of attributes with
log.attributes = {
:user_id => user_id,
:controller => controller,
...etc
}
and then calls
log.save
So I'm leaning towards it not being dodgy invocation. Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
mysql2
对于很多人来说工作得很好,但是它在常见任务中为了性能而无耻地牺牲了 MySQL C API 的一致性。也许,如果 request_logger 足够低级,它期望存在但不存在的调用。切换回使用 mysql 很简单 - 尝试一下,如果有效,请坚持使用。请记住更改您的
Gemfile
和config/database.yml
设置。mysql2
works fine for a lot of people, but it unashamedly sacrifices conformance to the MySQL C API for performance in the common tasks. Perhaps, if request_logger is low-level enough, it's expecting calls to exist which don't.It's trivial to switch back to using
mysql
- give it a try, and if it works, stick with it. Remember to change both yourGemfile
and yourconfig/database.yml
settings.事实证明,rails 2 和 3 之间的行为似乎发生了变化(我们在 Rails 2 中具有相同的设置,运行良好)。
我们使用 database.yml 指定一个(空)“主”数据库,然后输入我们的数据库具有分片+章鱼的客户。
为了简单起见,主数据库是 sqlite,并且似乎 activerecord 正在将针对 sqlite 格式化的请求发送到 mysql2 分片,无论其适配器类型如何。
It turned out to be what seems to be a change in behaviour between rails 2 and 3 (we have the same setup working fine in rails 2)
We use database.yml to specify an (empty) "master" database and then feed in our clients with shards+octopus.
The master db is sqlite for simplicity, and it seems that activerecord was feeding off requests formatted for sqlite to the mysql2 shards, regardless of their adaptor type.