digital-fabric / extralite

Ruby on SQLite
http://www.rubydoc.info/gems/extralite
MIT License
252 stars 8 forks source link

Sequel adapter can't be used with setup_regexp_function: true #57

Closed paddor closed 8 months ago

paddor commented 9 months ago

A regexp function (for the REGEXP SQL operator) can't be created because Extralite::Database#create_function is missing:

Sequel::DatabaseConnectionError: NoMethodError: undefined method `create_function' for #<Extralite::Database:0x00007f5d00ae4098 :memory:>

PR #56 also depends on this.

noteflakes commented 8 months ago

This is definitely a WONTFIX. Due to performance and concurrency concern, Extralite does not support calling back into Ruby code while running SQLite queries. This means that you cannot define functions, aggregations, collations etc in Ruby. If you wish to do so, you'll have to use the sqlite3-ruby gem.

FWIW, the sqlean collection of SQLite extensions includes a regexp extension that works great, is fast, and provides multiple functions for working with regexps.

paddor commented 8 months ago

No problem. But in that case I suggest removing at least these lines: https://github.com/digital-fabric/extralite/blob/main/lib/sequel/adapters/extralite.rb#L127-L131

Personally I don't use this gem yet. Given the recent improvements in Sequel regarding Regexp caching (shameless plug) I just wanted to ensure drop-in compatibility with this gem.