gpt4 book ai didi

ruby-on-rails - ruby (续集): filtering by date (year) and attribute

转载 作者:搜寻专家 更新时间:2023-10-30 21:52:14 24 4
gpt4 key购买 nike

使用 Sequel,我需要找到在 2012 中创建且标题为 @title 的所有文档。

$dataset = DB[:documents]
$dataset.select(:title).where(:created_at.extract(:year) => 2012, title: @title).all

但这不会返回任何内容,而是返回两个文档。

最佳答案

您没有提及您使用的是什么数据库,但如果您使用的是 SQLite,则需要设置 DB.use_timestamp_timezones = false 并清理数据库中的所有时间戳以删除时区。 Sequel 默认在 SQLite 上使用时区,但 SQLite 的日期/时间函数无法识别带有时区的时间戳。

如果您没有使用 SQLite,您应该提供有关您的情况的更多详细信息。

关于ruby-on-rails - ruby (续集): filtering by date (year) and attribute,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12436259/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com