开发者

mysql2 driver seems to write invalid queries

I'm developing an application l开发者_如何学Goayer 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?


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 your Gemfile and your config/database.yml settings.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜