【发布时间】:2011-10-13 22:19:08
【问题描述】:
我在使用 SQLite3 数据库的 Rails 3 中有以下语句:
word = 'Hello'
word_entry = Word.where("name REGEXP :word", {:word => "[[:<:]]#{word}[[:>:]]"})
但是,在 SQLite3 下运行它时,我不断得到:
SQLite3::SQLException: 没有这样的函数:REGEXP
我在 SQLite3 文档中读到它确实支持 REGEXP 函数。 在我的 gemfile 中,我有一行
gem 'sqlite3'
我的数据库配置文件如下所示:
development:
adapter: sqlite3
database: db/development.sqlite3
pool: 5
timeout: 5000
有什么想法吗?
解决方案: 我最终找到了this solution。不幸的是,它不适用于 Rails 3。 所以为了使用正则表达式,我最终改用 MYSQL 而不是 SQLite3。
【问题讨论】:
标签: sql ruby-on-rails ruby regex sqlite