如何设置 mysql2 时区选项以删除查询警告

发布于 2024-10-08 21:05:10 字数 634 浏览 0 评论 0原文

当使用 mysql2 进行查询时,我总是收到警告

/usr/local/lib/ruby/gems/1.9.1/gems/mysql2-0.2.6/lib/active_record/connection_adapters/mysql2_adapter.rb:463: warning: :database_timezone option must be :utc or :local - defaulting to :local

我确实看到了一个时区选项

Mysql2 现在支持两个时区选项:

  :database_timezone - this is the timezone Mysql2 will assume fields are already stored as, and will use this when creating the initial Time objects in ruby
  :application_timezone - this is the timezone Mysql2 will convert to before finally handing back to the caller

有人知道吗,如何使用以及在哪里设置此选项?

谢谢。

I always get warning when use mysql2 do query

/usr/local/lib/ruby/gems/1.9.1/gems/mysql2-0.2.6/lib/active_record/connection_adapters/mysql2_adapter.rb:463: warning: :database_timezone option must be :utc or :local - defaulting to :local

I did see a option for Timezones

Mysql2 now supports two timezone options:

  :database_timezone - this is the timezone Mysql2 will assume fields are already stored as, and will use this when creating the initial Time objects in ruby
  :application_timezone - this is the timezone Mysql2 will convert to before finally handing back to the caller

did any one know, how to usage, and where to set this option?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

疾风者 2024-10-15 21:05:10

这就是我修复它的方法:

config.active_record.default_timezone = :utc

This is how I had fixed it:

config.active_record.default_timezone = :utc
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文