相关疑难解决方法(0)

如何在SQLite3和Rails 3.1中打开REGEXP?

我使用SQLite3数据库在Rails 3中有以下语句:

word = 'Hello'
word_entry = Word.where("name REGEXP :word", {:word => "[[:<:]]#{word}[[:>:]]"})
Run Code Online (Sandbox Code Playgroud)

但是,在SQLite3下运行时,我会继续:

SQLite3 :: SQLException:没有这样的函数:REGEXP

我在SQLite3文档中读到它确实支持REGEXP函数.在我的gemfile中,我有这条线

gem 'sqlite3'
Run Code Online (Sandbox Code Playgroud)

我的数据库配置文件如下所示:

development:
  adapter: sqlite3
  database: db/development.sqlite3
  pool: 5
  timeout: 5000
Run Code Online (Sandbox Code Playgroud)

有什么想法发生了什么?

解决方案: 我最终找到了这个解决方案.不幸的是,它不适用于Rails 3.因此,为了使用正则表达式,我最终切换到MYSQL而不是SQLite3.

ruby regex sql sqlite ruby-on-rails

10
推荐指数
2
解决办法
7309
查看次数

标签 统计

regex ×1

ruby ×1

ruby-on-rails ×1

sql ×1

sqlite ×1